![](/img/trans.png)
[英]how to get textview below another textview in row in android linear layout
[英]How can I get a textview to appear below another textview? Android
我正在構建一個小的Android應用程序,我想在textview下顯示文本。我似乎無法得到它。 此時文本位於列表項的右側。 我希望帶有id的視圖,“list_size”低於標題。 這是代碼:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
android:background="?android:attr/activatedBackgroundIndicator"
>
<!--suppress AndroidLintContentDescription -->
<ImageView android:id="@+id/imageone"
android:layout_width="@dimen/list_item_image"
android:layout_height="@dimen/list_item_image"
android:layout_centerVertical="true"
android:scaleType="fitXY"/>
<TextView android:id="@+id/title" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:fontFamily="sans-serif-light"
android:textIsSelectable="false" android:layout_marginLeft="7dp"
android:layout_toRightOf="@+id/imageone" android:textSize="@dimen/medium_text_size"
android:singleLine="true" android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/divider"/>
<View android:id="@+id/divider"
android:layout_toLeftOf="@+id/list_size"
android:layout_width="1dp"
android:layout_height="10dp"/>
<TextView android:layout_marginLeft="5dp"
android:id="@+id/list_size" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textSize="@dimen/small_text_size"
android:singleLine="true" android:fontFamily="sans-serif-light"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"/>
</RelativeLayout>
你會想要使用android:layout_below
<TextView android:layout_marginLeft="5dp"
android:id="@+id/list_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/small_text_size"
android:singleLine="true"
android:fontFamily="sans-serif-light"
android:layout_alignParentRight="true"
android:layout_below="@id/title"/>
關於什么:
機器人:方向=“垂直”
<TextView android:layout_marginLeft="5dp"
android:id="@+id/list_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/small_text_size"
android:singleLine="true"
android:fontFamily="sans-serif-light"
android:layout_below="@id/title" />
<TextView android:layout_marginLeft="5dp"
android:id="@+id/list_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/small_text_size"
android:singleLine="true"
android:fontFamily="sans-serif-light"
android:layout_toLeftOf="@+id/divider"
android:layout_below="@id/title"/>
但是你把這個放在父母的右邊。 如果不是另一個,這只是把這個textview放在另一個下面,但沒有對齊!
你可以在layout_width中輸入數值,並在你的第二個Textview中使用android:layout_alignTop給出第一個Textview的id ..
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.