我很抱歉,我知道這是一個簡單的問題,但我現在無法做到這一點。文字始終處於中心位置,如何?
我想要一個文本總是在中間,另一個在右邊。
但是,當文本太長時間,他們會彼此對話。
假設我希望第二個文本始終位於右側,並且第一個文本位於中間,但是當其中一個文本太長時,居中的文本必須向左移動。
我該怎麼做?
我寫這個,但它不能正常工作。
<RelativeLayout
android:id="@+id/workout_footer_text"
android:layout_width="match_parent"
android:layout_height="@dimen/workout_header_height"
android:background="@color/green"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingLeft="@dimen/activity_horizontal_margin">
<TextView
android:id="@+id/review_comments_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/text_color_white"
android:textSize="@dimen/review_top_text_size"
android:singleLine="true"
android:gravity="center"
android:layout_toLeftOf="@+id/review_write_label"
android:layout_centerInParent="true"
android:layout_gravity="center"/>
<TextView
android:id="@+id/review_write_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/text_color_white"
android:layout_alignParentRight="true"
android:gravity="center_vertical"
android:singleLine="true"
android:layout_marginLeft="20dp"
android:textSize="@dimen/review_top_text_size"
android:layout_centerVertical="true"/>
</RelativeLayout>
聽起來像是'maxWidth'可以與下面的答案(S)組合使用。 – stkent