Android Api Demos登顶之路(六十三)Content-->Resources Smallest Width
来源:互联网 发布:软件招聘平台 编辑:程序博客网 时间:2024/06/05 03:01
这个demo演示 的主要是布局文件的技巧。
本例的基本思路是:
1.创建一个布局文件activity_row
该布局中只是定义了两个文本框,通过layout_weight属性,设置两个TextView平均分配屏幕的宽度。
需要注意的是这里使用了Merge节点。该节点可以使被include引用的布局在被嵌入父级结构中后可以很好的将它所包含的子集融合到父级结构中,而不会出现冗余的节点。
<?xml version="1.0" encoding="utf-8"?><merge xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal"> <TextView android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="Default width #1" android:layout_marginLeft="4dp" android:layout_marginRight="4dp" android:background="#800000ff"/> <TextView android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="Default width #2" android:layout_marginLeft="4dp" android:layout_marginRight="4dp" android:background="#800000ff"/> </LinearLayout></merge>
2.activity_coluns.xml。在该布局中定义了两个均分屏幕剩余高度的FrameLayut。
并在该FrameLayout使用include引入了上面设置的布局
<?xml version="1.0" encoding="utf-8"?><merge xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <FrameLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:padding="4dp" android:background="#8000ff00"> <include layout="@layout/activity_row"/> </FrameLayout> <FrameLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:padding="4dp" android:background="#8000ff00"> <include layout="@layout/activity_row"/> </FrameLayout> </LinearLayout></merge>
3.定义主布局,activity_main,只是定义了一个TextView尔后将剩余的界面都归属了一个Framelayout.并在FrameLayout当中引入了activity_coluns.xml。这个布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:padding="4dp"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" android:textAppearance="?android:attr/textAppearanceMedium" android:text="@string/info" /> <FrameLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="@android:drawable/gallery_thumb"> <include layout="@layout/activity_colums"/> </FrameLayout></LinearLayout>
0 0
- Android Api Demos登顶之路(六十三)Content-->Resources Smallest Width
- Android Api Demos登顶之路(五十九)Content-->Assets
- Android Api Demos登顶之路(六十)Content-->ClipBoard
- Android Api Demos登顶之路(六十一)Content-->PickContacts
- Android Api Demos登顶之路(六十二)Content-->Change Contacts
- Android Api Demos登顶之路(六十四)Content-->External Storage
- Android Api Demos登顶之路(二)
- Android Api Demos登顶之路(三)
- Android Api Demos登顶之路(四)
- Android Api Demos登顶之路(五)
- Android Api Demos登顶之路(六)
- Android Api Demos登顶之路(七)
- Android Api Demos登顶之路(八)
- Android Api Demos登顶之路(九)
- Android Api Demos登顶之路(十)Overscan
- Android Api Demos登顶之路(十一)Persistent state
- Android Api Demos登顶之路(十二)Presentation
- Android Api Demos登顶之路(十四)Quick Contacts
- TextView实现跑马灯效果
- 正则表达式的学习与小结
- 款流行的Markdown编辑器
- Linux常用命令——搜索which,whereis,slocate,find,grep
- NULL指针、零指针、野指针
- Android Api Demos登顶之路(六十三)Content-->Resources Smallest Width
- 关于JS单选按钮与复选按钮验证是否选中
- 软件体系结构网站
- C++Primer第五版 2.3.2节练习
- LIBTIFF配置方法总结
- java之代理
- poj 2186 Popular Cows 有向图强连通分量 tarjan
- 数组和面向对象(封装)
- ubuntu14.04更新源出错解决