【发布时间】:2015-02-10 14:27:32
【问题描述】:
我试图让一个视图覆盖另一个视图。这是我的 XML:
<RelativeLayout
android:background="@android:color/black"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="1"
android:id="@+id/test"
android:clipChildren="false"
android:scrollbarStyle="outsideOverlay" >
<RadioGroup
android:id="@+id/radioButtonGroup"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_horizontal"
android:paddingTop="?android:attr/actionBarSize">
<RadioButton
android:button="@null"
android:checked="true"
android:contentDescription="ZONA"
android:background="@drawable/tab_back_selector"
android:textColor="@color/tab_text_color"
android:textSize="12sp"
android:layout_weight="1"
android:id="@+id/tabZoneHome"
android:padding="14dp"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/home_tab_zone"
android:gravity="center"/>
<RadioButton
android:button="@null"
android:contentDescription="VISITADAS"
android:background="@drawable/tab_back_selector"
android:textColor="@color/tab_text_color"
android:textSize="12sp"
android:layout_weight="1"
android:id="@+id/tabVisitedHome"
android:padding="14dp"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/home_tab_visited"
android:gravity="center"
android:checked="false" />
<RadioButton
android:button="@null"
android:contentDescription="SUGERENCIAS"
android:background="@drawable/tab_back_selector"
android:textColor="@color/tab_text_color"
android:textSize="12sp"
android:layout_weight="1"
android:id="@+id/tabSuggestionsHome"
android:padding="14dp"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/home_tab_suggestions"
android:gravity="center"
android:checked="false" />
</RadioGroup>
<FrameLayout
android:id="@+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/radioButtonGroup" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="6dp"
android:background="@drawable/quickview_top_gradient"/>
<ImageView
android:id="@+id/img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
我希望 RadioGroup 高于 frame_container,但到目前为止还没有运气。我在java中尝试了以下内容:
RadioGroup myButton = (RadioGroup) ((Activity) context).findViewById(R.id.radioButtonGroup);
RelativeLayout layout = (RelativeLayout)((Activity)context).findViewById(R.id.test);
layout.bringChildToFront(AdsRecycler.this);
layout.invalidate();
然而什么都没有改变。 Radio Group 不会覆盖 frame_container。我做错了什么?
【问题讨论】: