2017-03-17 93 views
1

我正面临一个问题,当我从下面充气片段时,重叠片段。自定义视图片段重叠三星设备上的其他片段

enter image description here 这是在布局代码:

<FrameLayout 
     android:id="@+id/nonAdParent" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@color/white_blur"> 

     <FrameLayout 
      android:id="@+id/collage_view_container" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="@color/white_blur" 
      android:layout_marginBottom="@dimen/collageview_margin" /> 

     <FrameLayout 
      android:id="@+id/menu_footer" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="bottom" 
      android:background="@color/colorSecondary" /> 
    </FrameLayout> 

片段 “collage_view_container” 含有1个自定义视图和片段 “menu_footer” 包含水平recyclerview。

这是代码编程:

getSupportFragmentManager().beginTransaction() 
      .add(R.id.collage_view_container, new CollageContainerFrag().setLayoutModel(model)).commit(); 

    FooterMenuFragment footerFrag = new FooterMenuFragment(); 
    getSupportFragmentManager().beginTransaction() 
      .setCustomAnimations(R.anim.slide_in_up, R.anim.no_anim) 
      .add(R.id.menu_footer, footerFrag).commit(); 

问题:在 “collage_view_container” 片段自定义视图中重叠 “menu_footer” SAMSUNG设备上单独片段水平recyclerview。 如果我的配置行这段代码:

if (SystemUtils.isSamsungDevice()) { 
     getView().setLayerType(View.LAYER_TYPE_SOFTWARE, null); 
} 

则发行不出现,但应用程序将处理“慢慢来”。否则,问题再次出现。

这是整个视图的代码,其中“nonAdParent”framelayout位于。

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout  
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/white_blur" 
    android:clipChildren="true" 
    android:clipToPadding="false" 
    android:fitsSystemWindows="true"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 

    <include layout="@layout/toolbar" /> 

    <com.google.android.gms.ads.AdView 
     android:id="@+id/adView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     ads:adSize="SMART_BANNER" 
     ads:adUnitId="ca-app-pub-3940256099942544/6300978111"/> 

    <FrameLayout 
     android:id="@+id/adParent" 
     android:layout_width="match_parent" 
     android:layout_height="20dp" 
     android:visibility="gone" /> 

    <FrameLayout 
     android:id="@+id/nonAdParent" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@color/white_blur"> 

     <FrameLayout 
      android:id="@+id/collage_view_container" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="@color/white_blur" 
      android:layout_marginBottom="@dimen/collageview_margin" /> 

     <FrameLayout 
      android:id="@+id/menu_footer" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="bottom" 
      android:background="@color/colorSecondary" /> 
    </FrameLayout> 

P.S.请告诉是否需要更多代码。提前致谢。

+0

的FrameLayout应该被用来保存单个子视图,因为它可以是难以组织的方式,就是扩展到不同的子视图屏幕尺寸没有儿童重叠。所以你应该使用相对布局作为你的父布局,而不是框架布局。 –

+0

@sunilkushwah谢谢;我尝试使用RelativeLayout来代替FrameLayout的父布局,但它不起作用。 –

+0

你可以分享你的代码在哪里使用过我编辑过的相对布局 –

回答

0

更换您的框架布局(nonAdParent)下面

给出的代码部分
<RelativeLayout 
     android:id="@+id/nonAdParent" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@color/white_blur"> 

     <FrameLayout 
      android:id="@+id/collage_view_container" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="@color/white_blur" 
      android:layout_alignParentTop="true" 
      android:layout_marginBottom="@dimen/collageview_margin" /> 

     <FrameLayout 
      android:id="@+id/menu_footer" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="bottom" 
      android:layout_below="@+id/collage_view_container" 
      android:background="@color/colorSecondary" /> 
    </RelativeLayout> 
+0

我试过你的代码,但它不工作:( –