android *** Layout 01

来源:互联网 发布:数据分析师笔试逻辑 编辑:程序博客网 时间:2024/06/14 23:50

学习了android xml的线性布局


<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="vertical"        <LinearLayout     android:layout_width="match_parent"    android:layout_height="wrap_content"     android:background="#CCCCCC"    android:layout_gravity="center_vertical"    android:gravity="center"    >            <Button        android:id="@+id/button1"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="Button" />            </LinearLayout></LinearLayout>

其中layout_width与layout_height可用 match_parent与wrap_content,第一个是view的比例大小适合父类的大小,第二种是大小刚好适合内容的大小。
android:orientation是说线性布局的对齐模式是垂直还是水平,一个LinearLayout里可以嵌套多个LinearLayout。
layout_gravity来说明布局的位置,gravity来说明布局中内容在布局中的位置。
大概就酱。


0 0
原创粉丝点击