Как добиться двух строк в RelativeLayout - PullRequest
0 голосов
/ 24 октября 2011

Я хочу разместить один TextView в левом верхнем углу (0,0), один TextView в правом верхнем углу (0,1) и LinearLayout внизу (1,0 и 1,1). Я пытался как

<RelativeLayout
    android:id="@+id/rlHeader"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
>

<TextView
    android:id="@+id/txtLowerBound"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:text=" "    
>
</TextView>
<TextView
    android:id="@+id/txtUpperBound"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
>
</TextView>
<LinearLayout
    android:id="@+id/llRatingNumbers"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_alignParentTop="true"
    android:layout_gravity="bottom"
    android:gravity="bottom"
    android:layout_below="@id/txtUpperBound"
    android:layout_alignParentBottom="true"
></LinearLayout>
</RelativeLayout>

но отображает все в один ряд. Что изменить, чтобы иметь две строки, в верхних двух TextView и в нижней строке LinearLayout?

Ответы [ 2 ]

0 голосов
/ 24 октября 2011

попробуйте это:

<TextView
    android:id="@+id/txtLowerBound"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:text=" "    
>
</TextView>
<TextView
    android:id="@+id/txtUpperBound"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:layout_toRightOf="@id/txtLowerBound"
>
</TextView>
<LinearLayout
    android:id="@+id/llRatingNumbers"
    android:background="#FF55AD"
    android:layout_width="fill_parent"
    android:layout_height="85dp" //just for example 
    android:orientation="horizontal"
    android:layout_alignParentBottom="true"
    android:layout_gravity="bottom"
></LinearLayout>
</RelativeLayout>

Я не знаю, хотите ли вы, чтобы ваш linearLayout находился внизу вашего textView (если вы хотите, чтобы ваш макет находился под textview, поэтому измените атрибут: alignParentBottom с android:layout_below="@id/txtUpperBound") или внизу ваш экран (в моем ответе linearLayout будет внизу экрана),

0 голосов
/ 24 октября 2011
<LinearLayout
    android:id="@+id/llRatingNumbers"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_below="@id/txtUpperBound"
    android:layout_alignParentLeft="true"
></LinearLayout>

попробуйте это для вашего linearLayout.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...