How to add a layout below a view
I want to add a Relative Layout below a TextView and above a Button. My buttons are in a LinearLayout and the parent is a RelativeLayout.
Here is My code.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/iWantPageLogo"
android:layout_width="45dp"
android:layout_height="45dp"
android:src="@drawable/wic_logo_small" />
<Button
android:id="@+id/goButton_iWant"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="@string/go" />
<EditText
android:id="@+id/searchAutoCompleteTextView_iWant"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/goButton_iWant"
android:layout_toRightOf="@id/iWantPageLogo"
android:hint="@string/search" />
<TextView
android:id="@+id/iWantLabel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/iWantPageLogo"
android:gravity="center_vertical|center_horizontal"
android:text="@string/iWant"
android:textColor="@color/white" />
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:="@+id/iWantLabel">
<TextView
android:id="@+id/iNeedToBuy"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/iWantPageLogo"
android:gravity="center_vertical|center_horizontal"
android:text="@string/iNeedToBuy"
android:textColor="@color/white" />
<EditText
android:id="@+id/iNeedToBuyEditText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/iNeedToBuy"
android:hint="@string/product"
android:textColor="@color/black" />
</RelativeLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<Button
android:id="@+id/feedButton_feed"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_margin="0dp"
android:layout_weight="1"
android:background="@color/white"
android:text="@string/feed"
android:textColor="@color/black" />
<Button
android:id="@+id/iWantButton_feed"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_margin="0dp"
android:layout_weight="1"
android:background="@color/white"
android:text="@string/iwant"
android:textColor="@color/black" />
<Button
android:id="@+id/shareButton_feed"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_margin="0dp"
android:layout_weight="1"
android:background="@color/white"
android:text="@string/share"
android:textColor="@color/black" />
<Button
android:id="@+id/profileButton_feed"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_margin="0dp"
android:layout_weight="1"
android:background="@color/white"
android:text="@string/profile"
android:textColor="@color/black" />
</LinearLayout>
</RelativeLayout>
My Relative Layout(which contains TextView and EditText) which is in the parent layout(RelativeLayout) to be below iWantLabel and above the Linear Layout which contains buttons. How to achieve this
you pretty much know everything and need just a little attention. 1) you need to mention the place of all your layouts relative to other views as below or above. because some of their hight is fill_parrent which causes problems (overlapping the others) when the place is not mentioned clearly 2) you need to give an id to your linear layout 3) you need to set the place of your relative layout using layout_below and layout_above
链接地址: http://www.djcxy.com/p/16652.html上一篇: 如何在标签视图中显示文件?
下一篇: 如何在视图下添加布局