我正在尝试将我的进度屏幕(@+id/progressScreen
)置于我的回收站视图(@+id/cardList
)之上,但由于某种原因,回收站视图始终位于顶部并隐藏它。我已经尝试了View.bringToFront()
,但它没有工作
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:background="@drawable/gradient"
tools:showIn="@layout/activity_main"
android:id="@+id/root_layout"
tools:targetApi="LOLLIPOP">
<RelativeLayout
android:elevation="5dp"
android:id="@+id/relativeToolbar"
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="?attr/colorPrimary" />
<RelativeLayout
android:elevation="5dp"
android:layout_marginRight="12dp"
android:layout_marginLeft="12dp"
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:background="@color/white"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:elevation="3dp"
android:id="@+id/cardList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal|top" />
<com.google.android.gms.common.SignInButton
android:id="@+id/sign_in_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:visibility="gone"
>
</com.google.android.gms.common.SignInButton>
<RelativeLayout
android:id="@+id/progressScreen"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#30FFFFFF"
android:visibility="visible">
<TextView
android:id="@+id/progressText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/progressbar"
android:layout_centerHorizontal="true"
android:layout_marginBottom="67dp"
/>
<ProgressBar
android:id="@+id/progressbar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"/>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
答案 0 :(得分:2)
android:id="@+id/progressView"
的RelativeLayout置于RecyclerView之上,然后添加 android:translationZ 参数以更正Z索引,因为您正在使用RV的3dp高程。因此,要在RecyclerView android:translationZ="4"
之上
这是固定代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:background="@drawable/gradient"
tools:showIn="@layout/activity_main"
android:id="@+id/root_layout"
tools:targetApi="LOLLIPOP">
<RelativeLayout
android:elevation="5dp"
android:id="@+id/relativeToolbar"
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="?attr/colorPrimary" />
<RelativeLayout
android:elevation="5dp"
android:layout_marginRight="12dp"
android:layout_marginLeft="12dp"
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:background="@color/white"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/progressScreen"
android:layout_width="match_parent"
android:layout_height="wrap_content"**
android:translationZ="4dp"
android:background="#30FFFFFF"
android:visibility="visible">
<TextView
android:id="@+id/progressText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/progressbar"
android:layout_centerHorizontal="true"
android:layout_marginBottom="67dp"
/>
<ProgressBar
android:id="@+id/progressbar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"/>
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:elevation="3dp"
android:id="@+id/cardList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal|top" />
<com.google.android.gms.common.SignInButton
android:id="@+id/sign_in_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:visibility="gone"
>
</com.google.android.gms.common.SignInButton>
</RelativeLayout>
</RelativeLayout>