Android 隐藏在回收器视图后面的相对布局
我正试图将我的进度屏幕(Android 隐藏在回收器视图后面的相对布局,android,Android,我正试图将我的进度屏幕(@+id/progressScreen)放在我的回收器视图(@+id/cardList)的顶部,但由于某些原因,回收器视图总是位于顶部并将其隐藏。我已经尝试了View.bringToFront(),但它不起作用 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns
@+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>
对不起,我看错了。您应该首先将android:id=“@+id/progressView”
的RelativeLayout放在RecyclerView的顶部,然后添加android:translationZ参数以更正Z索引,因为您正在为RV使用3dp高程。因此,要在RecyclerViewandroid: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>
对不起,我看错了。您应该首先将android:id=“@+id/progressView”
的RelativeLayout放在RecyclerView的顶部,然后添加android:translationZ参数以更正Z索引,因为您正在为RV使用3dp高程。因此,要在RecyclerViewandroid: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>
前面的答案不完全正确,因为您只想在RV顶部显示@+id/progressScreen,而我将RV移动到@+id/progressScreen下方。请检查上次编辑的代码,它现在应该是正确的,并在RV顶部显示@+id/progressScreen。前面的答案不完全正确,因为您只想在RV顶部显示@+id/progressScreen,而我将RV移到@+id/progressScreen下方。请检查上次编辑的代码,它现在应该是正确的,并在RV顶部显示@+id/progressScreen。