在HTML中,如果我想用一个蓝色覆盖到完全覆盖一个黄色横幅,我可以做到这一点:在相同的父级布局下,如何使match_parent元素的大小跟随wrap_content元素?
<div style="position:relative;display:table;">
<div style="background-color:yellow;font-size:30px;">TESTING<div/>
<div style="z-index:1;position:absolute;top:0px;left:0px;width:100%;height:100%;background-color:blue;opacity:0.5;display:inline-block;"></div>
</div>
其中蓝色覆盖物的大小可以按照黄色旗帜,尽管我不知道它的实际px。
我想实现在它的Android一样的效果,我想:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:background="#FFFF00"
android:textSize="30dp"
android:id="@+id/textview"
android:text="TESTING"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:alpha="0.5"
android:background="#0000FF"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignBottom="@+id/textview"
</RelativeLayout>
但蓝色覆盖的宽度不遵循即使我设置的Android封闭WRAP_CONTENT元素:layout_alignBottom:
我该如何获得与html相同的效果?