我有一些有自己的寬度和高度比例的響應式佈局的彩色區域。我想粘貼一個視圖,例如,TextView的紅色區域爲:如何從父視圖中取消限制視圖的大小(保留wrap_content的大小)?
其中TextView的保留自己原來的大小,而不是由紅色區域的限制。
我想:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<View
android:background="#FFFF77"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.2"/>
<LinearLayout
android:clipChildren="false"
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="0.01">
<View
android:clipChildren="false"
android:background="#77FFFF"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.2"/>
<RelativeLayout
android:id="@+id/progressBar"
android:clipChildren="false"
android:background="#FF0000"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.01">
<TextView
android:textAlignment="center"
android:gravity="center"
android:textSize="20dp"
android:text="abcde"
android:textColor="#000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
<View
android:clipChildren="false"
android:background="#77FFFF"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.1"/>
</LinearLayout>
<View
android:background="#FFFF77"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.1"/>
</LinearLayout>
它已經被設置機器人:clipChildren =爲中間元素 「假」,但TextView的規模似乎仍然由紅色框的限制:
如何讓TextView的大小不受限制,使其看起來像粘在紅色區域上?
注:在實踐中,除了紅色區域,其他區域將變成透明的,所以不用擔心黃色和青色區域將阻止TextView的