卡片视图显示在其他片段上

时间:2018-01-24 06:12:32

标签: android android-layout android-fragments android-recyclerview android-cardview

我在主屏幕上设置了CardViewRecyclerView)。因此,当我尝试浏览NavigationDrawer并切换到其他Fragment时,CardView会显示在其上方(是的,我使用了回收站视图) 有人可以帮忙吗?

添加了包含卡片视图的项目布局(xDDD更多详细信息)

activity_main.xml中

<android.support.v4.widget.DrawerLayout    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:id="@+id/dl"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.wallpaperstore.thelastofuswallpapersandwalkthrough.MainActivity">
<FrameLayout
    android:background="@color/white"
    android:id="@+id/flcontent"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >


</FrameLayout>

<android.support.v7.widget.RecyclerView
    android:id="@+id/recyclerView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clipChildren="false">

</android.support.v7.widget.RecyclerView>



<android.support.design.widget.NavigationView
    app:headerLayout="@layout/header"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/Navigation_v"
    app:menu="@menu/nav_menu"

    android:layout_gravity="start" >
</android.support.design.widget.NavigationView>


</android.support.v4.widget.DrawerLayout>

fragment_walkthrough.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.wallpaperstore.thelastofuswallpapersandwalkthrough.Walkthrough">

<!-- TODO: Update blank fragment layout -->


<WebView
    android:id="@+id/webView"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

项目布局

 <android.support.v7.widget.CardView
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="wrap_content"
android:layout_margin="10dp"
app:cardElevation="10dp">

<com.battleent.ribbonviews.RibbonLayout
    android:id="@+id/ribbonLayout"
    android:layout_width="match_parent"
    android:layout_height="210dp"
    app:bottom_ribbonColor="#FFFFFF"
    app:bottom_textColor="@android:color/white">

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="fitXY" />


    <Button
         android:id="@+id/button9"
        style="@style/Widget.AppCompat.Button.Borderless.Colored"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:text="Set Wallpaper"
        android:textColor="@color/darkgray"
        tools:text="@string/bottom_sheet_behavior" />


 </com.battleent.ribbonviews.RibbonLayout>

</android.support.v7.widget.CardView>

1 个答案:

答案 0 :(得分:0)

尝试使用

fragmentManager.beginTransaction().replace(container, newFragment).commit();

而不是添加片段

相关问题