我在视图寻呼机VideoFragment和StoryFragment中有两个片段。 在Videofragment中,我设置以下行和视频视图以匹配父.-
getActivity().getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LOW_PROFILE
| View.SYSTEM_UI_FLAG_IMMERSIVE);
getActivity().getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
用户移动到肖像后我正在清除标志 -
metrics2 = new DisplayMetrics();
getActivity().getWindow().getDecorView()
.setSystemUiVisibility(View.SYSTEM_UI_FLAG_IMMERSIVE);
getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics2);
getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
所有这些都发生在VideoFragment中,但是当我滑动视图寻呼机时,下一个片段是具有以下布局的故事片段 -
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="@color/white"
android:gravity="center"
android:orientation="vertical">
<include
android:id="@+id/include_share_top"
layout="@layout/story_share_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_margin="0dp" />
<ScrollView
android:id="@+id/scroll_view_story"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/ad_id"
android:layout_below="@id/include_share_top"
android:layout_marginTop="0dp"
android:fillViewport="true">
<LinearLayout
android:id="@+id/ll_scrollview_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/ad_top"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:background="@color/light_grey"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="1dp"
android:paddingTop="1dp"
android:visibility="gone" />
<!-- This layout has imageview, this is not visible -->
<FrameLayout
android:id="@+id/flVideo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@color/black">
<LinearLayout
android:id="@+id/story_video_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:fitsSystemWindows="true"
android:gravity="center"
android:orientation="vertical" />
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/ivBackStoryImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:fitsSystemWindows="true"
android:scaleType="fitXY" />
<ImageView
android:id="@+id/ivPlay1"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:background="@drawable/video"
android:contentDescription="@string/abc_action_bar_home_description"
android:visibility="gone" />
<ProgressBar
android:id="@+id/pbPlay"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:indeterminate="true"
android:visibility="gone" />
</FrameLayout>
<RelativeLayout
android:id="@+id/flScroll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include
android:id="@+id/include_share_middle"
layout="@layout/story_share_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="visible" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/include_share_middle"
android:background="@color/black"
android:orientation="vertical">
<!-- This is webview which is covering whole space, it actually pushes the image view out of screen -->
<com.timesnowmobile.TimesNow.widgets.ObservableWebView
android:id="@+id/wvStoryhtml"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="20dp" />
<Button
android:id="@+id/btn_subscribe"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_gravity="center_horizontal|bottom"
android:layout_marginBottom="5dp"
android:background="@drawable/red_card_shape"
android:text="Subscribe"
android:textAllCaps="false"
android:textColor="@color/white"
android:visibility="gone" />
</FrameLayout>
</RelativeLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="@+id/ad_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/light_grey"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingBottom="1dp"
android:paddingTop="1dp"
android:visibility="gone" />
<com.timesnowmobile.TimesNow.widgets.FloatingActionButton
android:id="@+id/float_btn"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="50dp"
android:layout_marginRight="10dp"
android:clickable="true"
android:elevation="100dp"
android:visibility="visible">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0.50"
android:src="@drawable/related_stories" />
</com.timesnowmobile.TimesNow.widgets.FloatingActionButton>
</RelativeLayout>
Webview占据整个屏幕,将所有视图移至顶部。当我向下滚动时,我可以看到图像。只有当我在视频片段中进入横向模式时才会发生这种情况。我正在使用Exoplayer播放视频。
修改1
现在我将<ScrollView>
更改为<NestedScrollView>
并添加了此属性android:fillViewport =&#34; true&#34; 。
从风景画回到画像后,它不会崩溃但滚动不起作用。