【发布时间】:2015-09-01 11:45:25
【问题描述】:
我有一个视频活动,顶部带有标题,SeekBar 底部带有媒体控件。当触发触摸事件时,标题和SeekBar 布局都会覆盖在SurfaceView 上,并且它们会在一定时间后消失。我还实现了沉浸式模式,其中状态栏和导航栏与标题和SeekBar 一起消失。我已经设法使用以下属性为状态栏腾出空间,而不会覆盖在标题布局上。
android:fitsSystemWindows="true"
但是,如果我对屏幕底部的媒体控件布局使用相同的属性,它就不起作用。结果,导航栏覆盖在布局上。我不明白为什么上述属性在一种布局上运行良好,而在另一种布局上运行良好。我有一个自定义的媒体控件布局,我有一个扩展FrameLayout 的类。 fitSystemWindows 属性是否不适用于自定义布局?请参阅第一个屏幕截图中右下角的图标。如第二个屏幕截图所示,它被导航栏覆盖
我在下面包含了我的部分类文件和布局。
MediaController.java
public class MediaController extends FrameLayout {
//Some private fields are declared here
public MediaController(Context context, boolean useFastForward, boolean useFullScreenButton) {
super(context);
....
}
public MediaController(Context context) {
this(context, true, false);
}
@Override
public void onFinishInflate() {
if (mRoot != null)
initControllerView(mRoot);
}
//Inflating the layout here
protected View makeControllerView() {
LayoutInflater inflate = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mRoot = inflate.inflate(R.layout.media_controller, null);
....
return mRoot;
}
//Lot of other methods here
}
media_controller.xml
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:fitsSystemWindows="true"> <!--Using the attribute here-->
<ImageButton android:id="@+id/pause"
android:layout_gravity="top"
android:layout_width="30dp"
android:layout_height="30dp"
android:background="@android:color/transparent"/>
<TextView android:id="@+id/time_current"
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/white"/>
<SeekBar
android:id="@+id/mediacontroller_progress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="32dip" />
<TextView android:id="@+id/time"
android:layout_gravity="center_horizontal"
android:textColor="@color/white"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ImageButton android:id="@+id/fullscreen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:contentDescription="@string/description" />
</LinearLayout>
【问题讨论】:
-
我强烈建议您分享一个简短的视频(或屏幕截图)来解决问题,然后解释它应该如何工作。
-
@Nactus 我已经添加了截图。谢谢。
-
“请参阅第一个屏幕截图中右下角的图标。它被导航栏覆盖,如第二个屏幕截图所示”,所以如果我理解正确,您会喜欢在媒体播放器处于活动状态时隐藏导航栏,对吗? (第一张图是它的样子,第二张图是你得到的,对吗?)
-
我可以隐藏它,但是当我触摸屏幕时,我会看到你在第二张图片中看到的内容。我唯一不想要的是将导航栏覆盖在右下角的图标上。图标应向导航栏左侧移动。
标签: android seekbar navigationbar android-fullscreen