0

我正在研究具有底部FrameLayout和customview的代码。我在FrameLayout中加载了一个片段,里面有CoordinatorLayoutViewPager在frameLayout中加载时的坐标布局问题

所以问题是ViewPager需要手机的全部高度,并隐藏在customview后面的列表内容。这里是代码:

main_layout.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:fitsSystemWindows="true" 
    android:layout_height="match_parent"> 



    <FrameLayout 
     android:id="@+id/root_content" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_above="@+id/playerView" 
     android:layout_alignParentTop="true" /> 


    <TextView 
     android:id="@+id/playerView" 
     android:layout_width="match_parent" 
     android:layout_height="@dimen/player_size" 
     android:layout_alignParentBottom="true" 
     android:background="#D7D7D7" 
     android:gravity="center" 
     android:text="Player View" 
     android:textSize="20sp" /> 

</RelativeLayout> 

fragment_view.xml

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/main_content" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/appbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 


     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" 
      app:layout_scrollFlags="scroll|enterAlways" 
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> 

     <android.support.design.widget.TabLayout 
      android:id="@+id/tabs_view_tabs" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      app:layout_collapseMode="pin" 
      android:background="?attr/colorPrimary" 
      android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" /> 
    </android.support.design.widget.AppBarLayout> 

    <android.support.v4.view.ViewPager 
     android:id="@+id/tabs_view_viewpager" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 


</android.support.design.widget.CoordinatorLayout> 

enter image description here

在上图中可以看到列表中的部分内容被隐藏PlayerView旁边。

回答

0

尝试使用LinearLayoutlayout_weight代替RelativeLayoutinside main_layout.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:fitsSystemWindows="true" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <FrameLayout 
     android:id="@+id/root_content" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"/> 

    <TextView 
     android:id="@+id/playerView" 
     android:layout_width="match_parent" 
     android:layout_height="@dimen/player_size" 
     android:background="#D7D7D7" 
     android:gravity="center" 
     android:text="Player View" 
     android:textSize="20sp" /> 

</LinearLayout> 
+0

我只是想你的代码......不是为我工作,仍然是内容已被隐藏在上面的图片:| –

+0

尝试删除此android:fitsSystemWindows =“true”属性并让我知道。 –

+0

同样问题的队友... –