首页 > 代码库 > android实现综合布局
android实现综合布局
要实现这种效果,
LinearLayout的嵌套实现 2.使用RelativeLayout
<?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" android:paddingLeft="10dp" android:paddingRight="10dp" > <EditText android:id="@+id/EditText1" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/reminder" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <EditText android:id="@+id/dates" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" /> <EditText android:id="@+id/times" android:layout_width="100dp" android:layout_height="wrap_content" /> </LinearLayout> <Button android:id="@+id/button1" android:layout_width="96dp" android:layout_height="wrap_content" android:layout_gravity="right" android:text="提交" /> </LinearLayout>
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="10dp" android:paddingRight="10dp" > <EditText android:id="@+id/EditText1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:hint="@string/reminder" /> <EditText android:id="@+id/dates" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/EditText1" android:layout_alignParentLeft="true" android:layout_toLeftOf="@+id/times" /> <EditText android:id="@+id/times" android:layout_width="100dp" android:layout_height="wrap_content" android:layout_below="@+id/EditText1" android:layout_alignParentRight="true" /> <Button android:id="@+id/button1" android:layout_width="96dp" android:layout_height="wrap_content" android:layout_below="@id/times" android:layout_alignParentRight="true" android:text="提交" /> </RelativeLayout> <!-- android:layout_alignParentLeft="true" 和父控件左对齐 android:layout_toLeftOf="@+id/times" 在指定组件左边 android:layout_below="@id/EditText1" 在指定组件下边 -->
本文出自 “matengbing” 博客,请务必保留此出处http://matengbing.blog.51cto.com/11395502/1880754
android实现综合布局
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。