GL_BOOK_2

Chapter 3 UI
1 progressbar style = “?android:attr/progressBarStyleHorizontal”
2 AlertDialog.Builder.dialog = new AlertDialog.Builder(Activity activity);
dialog.setTitle(); dialog.setMessage();
dialog.setCancleable(false); //back键是无法取消的
dialog.setpositiveButton(“OK”,new DialogInterface.onClickListener(){
onclick();
});
dialogn.setNegativeButton(“Cancel” ,new DailogInterface.onclickListener(){
onclick();
})
dialog.show();
3 ProgressDialog dialog = new ProgressDialog(Activity );
dialog.setTitle(); dialog.setMessage();dialog.setcancelable(true);
dialog.show();
4 gravity :用于指定文字在控件中的对齐方式
layout_gravity 控件在父布局中的对齐方式
5 LinearLayout 中 horizental Edittext width = 0dp weight =1 右边是 Button width = wrapcontent .Edittext 沾满除Button 外的所有空间
6 TabLayout

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:stretchColumns="1"
    android:layout_height="match_parent" >

    <TableRow>

        <TextView
            android:layout_height="wrap_content"
            android:text="user : " />

        <EditText
            android:layout_height="wrap_content"
            android:hint="input user name" />
    </TableRow>

    <TableRow>

        <TextView
            android:layout_height="wrap_content"
            android:text="code : " />

        <EditText
            android:layout_height="wrap_content"
            android:hint="input your code" />
    </TableRow>
    <TableRow >
        <Button 
            android:layout_height="wrap_content"
            android:text="Login"
            android:layout_span = "2"
            android:gravity="center"
            />
    </TableRow>
</TableLayout>

TableRow 中不能指定控件的宽度 layout_span 意指占用两列 stretchColumns = n ; 1就是拉伸第二列 0 是拉伸第一列
7 View - ImageView \ TextView \ViewGroup
TextView - EditText \ Button
ViewGroup - LinearLayout\RelativeLayout —-
布局的复用

<include layout = @layout/title >

布局的复用以及布局的事件监听 自定义控件

8 ListView

ArrayAdapter<String> adapter = new ArrayAdapter<String>(Context ,android.R.layout.simple_list_item_1,String[]);

ListView.setSelection(int);
9 根据Android规定 160dpi 的屏幕上 1dp 等于 1px , 而在320dpi 的屏幕上, 1dp 等于 2px

10 Nine-Patch
sdk目录下 tools 文件夹下 draw9patch.bat 文件
File-open 9-patch xx.png
四个边框 画黑线 图片拉伸时会拉伸黑点标记的区域

==============
Chapter 4 碎片
1 静态添加碎片

<fragment
android:id = "@+id/id"
android:name = "com.xx.xx.fragment"
width
height
/>

2 动态添加碎片


    <Button 
        android:id="@+id/button"
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:text="click"
        />

    <FrameLayout 
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="match_parent"
        android:id="@+id/right"        
        >
        <fragment 
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:name="com.asen.demo.RightFragment"
            />
    </FrameLayout>

FragmentManager manager = getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
if (flag) {
RightFragmentNew f = new RightFragmentNew();
transaction.replace(R.id.right, f);
transaction.commit();
flag =false;
}else {
RightFragment f = new RightFragment();
transaction.replace(R.id.right, f);
transaction.addToBackStack(null);
transaction.commit();
flag = true;
}

碎片做到模拟Activity返回栈的处理 加上transaction.addToBackStack(null);

3 碎片和活动之间的通信
XXFragment f = (XXFragment)getFragmentManager().findFragmentById(R.id.xxfragment);

4 生命周期 onAttach onCreateView onActivityCreate onDestroyView() onDetach

5 使用限定符Qualifiers 动态加载
layout-large 文件夹 同名.xml 布局文件
使用最小宽度限定符 最小以 dp为单位 这个最小值为临界点 屏幕宽度大于 这个值得设备就加载一个布局 小于这个值 就加载另一个布局了 如layout-sw600dp文件夹
最小宽度限定符实在 3.2版本引入的

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值