您的位置:首页 > 移动开发 > Android开发

Android 相对布局 RelativeLayout

2016-04-10 13:03 471 查看
android 相对布局RelativeLayout

<pre name="code" class="html"><RelativeLayout 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"
tools:context="com.example.linearlayouttest.MainActivity" >

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="@string/bn1" />

<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/button1"
android:layout_alignStart="@id/button1"
android:text="@string/bn2" />

<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toStartOf="@id/button1"
android:layout_alignBaseline="@id/button1"
android:text="@string/bn3" />

<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/button1"
android:layout_alignStart="@id/button1"
android:text="@string/bn4" />

<Button
android:id="@+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@id/button1"
android:layout_alignBaseline="@id/button1"
android:text="@string/bn5" />

</RelativeLayout>






中间用到了

android:layout_toStartOf="@id/button1"  和 android:layout_toEndOf="@id/button1"
相当于 layout_toLeftOf  和 layout_toRightOf




                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息