[英]android textview right of a multiline textview
我想將TextView
放在多行TextView
右邊。
請檢查下面的代碼。
<RelativeLayout
android:id="@+id/rltest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/rlanswer"
android:layout_marginLeft="@dimen/grdiviewspacing"
android:layout_marginRight="@dimen/grdiviewspacing"
android:background="@android:color/transparent" >
<TextView
android:id="@+id/lblanswer2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:ellipsize="end"
android:lines="1"
android:text="@string/strbookmarkmessage"
android:textColor="@color/black"
android:textSize="@dimen/listviewlocationsize"
android:textStyle="bold" />
<TextView
android:id="@+id/btnyesiwillcollectitby"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip"
android:layout_toRightOf="@id/lblanswer2"
android:autoLink="all"
android:linksClickable="true"
android:text="@string/stryesiwillcollectitby"
android:textColor="@color/linkcolor"
android:textSize="@dimen/listviewlocationsize" />
</RelativeLayout>
我已經嘗試了上面的代碼的問題是它沒有顯示第二個TextView
。 我們在哪里,如果我嘗試layout_below
其顯示第二個文本視圖。 誰能幫我一個忙..我想要這樣的東西-藍色textview文本閱讀textview。
使用LinearLayout
代替RelativeLayout
並為兩個TextView
賦予layout_weight=1
,無論您想要什么,都會得到結果。
如果要繼續使用RelativeLayout
,則必須為TextView
“ lblanswer2”設置dip的寬度(而不是wrap_content),否則,如果文本較長,它將始終占據整個位置。
如果沒有必要使用RelativeLayout
則可以遵循pratik的回答並實現LinearLayout
,這樣,您的2個TextViews
將平等地共享寬度。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.