[英]coordinate layout issue while loading in frameLayout
I am working on code that have FrameLayout
and customview at bottom. 我正在研究底部具有
FrameLayout
和customview的代码。 I loaded a fragment inside FrameLayout, which is having CoordinatorLayout
with ViewPager
inside. 我在FrameLayout中加载了一个片段,该片段中包含带有
ViewPager
CoordinatorLayout
。
So problem is ViewPager
takes full height of the phone and hide contents of list behind customview. 因此问题是
ViewPager
占用了手机的全部高度,并将列表的内容隐藏在customview之后。 Here is Code: 这是代码:
main_layout.xml 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 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>
In above image you can see some content of list is hidden beside PlayerView. 在上图中,您可以看到PlayerView旁边隐藏了一些列表内容。
Try to use LinearLayout
with layout_weight
instead of RelativeLayout
inside main_layout.xml
尝试使用带有
layout_weight
LinearLayout
而不是inside main_layout.xml
的RelativeLayout
<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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.