我想设置" date_text"底部是其父底部的底部,但它占据了主父的底部。我试过跟着
<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" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:background="#FFFFFF"
tools:context=".MainActivity"
android:id="@+id/Layout">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<!-- Month and Year on the top -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#22C778"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="December 2014"
android:gravity="center"
android:id="@+id/month_name"
android:padding="5dp"
android:textColor="#FFFFFF"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<!-- Date and Month On The Left -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="30 Jan"
android:gravity="center_vertical"
android:background="#F1F1F1"
android:padding="10dp"
android:layout_marginTop="5dp"
android:id="@+id/date_text"
android:layout_below="@+id/month_name"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
/>
<!-- Question Title -->
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:padding="5dp"
android:text="This Is The Title Of Question Of January"
android:id="@+id/question_title"
android:layout_alignTop="@+id/date_text"
android:layout_toRightOf="@+id/date_text" />
</RelativeLayout>
我也尝试过使用layoutalignParentBottom =&#34; true&#34;但它没有工作
答案 0 :(得分:0)
如果您不想再添加任何内容,那么另一个RelativeLayout
内的RelativeLayout
似乎是多余的。如果您确实需要它,请将内部RelativeLayout
的高度设置为match parent
。对于textview,父级是内部RelativeLayout
,因为它的高度为wrap_content
,所以它将扩展到所需的高度
答案 1 :(得分:0)
试试这个布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/Layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<!-- Month and Year on the top -->
<TextView
android:id="@+id/month_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:background="#22C778"
android:gravity="center"
android:padding="5dp"
android:text="December 2014"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF" />
<!-- Date and Month On The Left -->
<TextView
android:id="@+id/date_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/month_name"
android:layout_marginTop="5dp"
android:background="#F1F1F1"
android:gravity="center_vertical"
android:padding="10dp"
android:text="30 Jan"
android:textAppearance="?android:attr/textAppearanceMedium" />
<!-- Question Title -->
<TextView
android:id="@+id/question_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/date_text"
android:layout_toRightOf="@+id/date_text"
android:background="#FFFFFF"
android:padding="5dp"
android:text="This Is The Title Of Question Of January" />
</RelativeLayout>
我希望这就是你想要的......