android之网格布局GridLayout

TableLayout(网格布局)

需要注意的:

网格布局需要最低版本支持:
API 14 也就是最低andriod4.0

layout/activity_main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<GridLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:columnCount="5"
android:orientation="horizontal">
<TextView android:text="用户名"/>
<EditText android:hint="请输入1-10个字符"
android:layout_columnSpan="4"
android:layout_gravity="fill_horizontal"
/>
<TextView android:text="密 码"/>
<EditText android:hint="请输入1-10个字符"
android:layout_columnSpan="4"
android:layout_gravity="fill_horizontal"
/>
</GridLayout>
<GridLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:columnCount="5"
android:orientation="horizontal">
<Button android:text="不"
android:visibility="invisible"/>
<Button android:text="登陆"
android:drawableLeft="@drawable/login32x32"
android:background="@drawable/btn_bg"
android:textColor="#FFF"/>

<Button android:text="不"
android:visibility="invisible"
/>
<Button android:text="退出"
android:drawableLeft="@drawable/exit32x32"
android:background="@drawable/btn_bg"
android:textColor="#FFF"/>
<Button android:text="不"
android:visibility="invisible"/>
</GridLayout>


</LinearLayout>

效果:

android之网格布局GridLayout

你可能感兴趣的:(android)