我想要实现的是类似于 Instagram 应用程序内网络浏览器,当您点击广告时使用:
我所做的,是我使用了一个 WebView bottomSheetDialogFragment,然后我重写onCreateDialog以获得这样的全屏:
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
BottomSheetDialog bottomSheetDialog=(BottomSheetDialog)super.onCreateDialog(savedInstanceState);
bottomSheetDialog.setOnShowListener(dialog -> {
BottomSheetDialog dialogc = (BottomSheetDialog) dialog;
FrameLayout bottomSheet = dialogc .findViewById(android.support.design.R.id.design_bottom_sheet);
BottomSheetBehavior.from(bottomSheet).setState(BottomSheetBehavior.STATE_EXPANDED);
//BottomSheetBehavior.from(bottomSheet).setSkipCollapsed(true);
//BottomSheetBehavior.from(bottomSheet).setHideable(true);
});
return bottomSheetDialog;
}
Run Code Online (Sandbox Code Playgroud)
这是我得到的结果:
我的问题是,如何获得全屏效果,或者如何实现类似 instagram 浏览器的功能?
ps:我首先尝试了 chrome 自定义选项卡,但无法将其添加到对话框片段中。
谢谢你。
android material-design bottom-sheet material-components material-components-android
我尝试使用支持库23.2.0中的新底页将底页扩展为全屏,如设计指南中所建议的那样
这个效果非常好,但是底页位于我的ActionBar和我的标签下.
怎么可以让底页超过工具栏?我的菜单结构如下:
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/appbar_padding_top">
<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|snap|enterAlways"
app:popupTheme="@style/AppTheme.PopupOverlay"/>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
<include
android:id="@+id/playerLayout"
layout="@layout/player_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:behavior_peekHeight="?attr/actionBarSize"
app:layout_behavior="@string/bottom_sheet_behavior"
app:model="@{model}"/>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
android android-support-library material-design androiddesignsupport
我正在寻找一种在状态栏后面绘制 BottomSheetDialogFragment 的解决方案。我尝试覆盖样式:
<style name="BaseBottomSheetDialog" parent="@style/Theme.Design.Light.BottomSheetDialog">
<item name="android:windowIsFloating">false</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowFrame">@null</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowAnimationStyle">@null</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowNoTitle">true</item>
<item name="bottomSheetStyle">@style/BottomSheet</item>
</style>
Run Code Online (Sandbox Code Playgroud)
但没有任何效果。我的父布局是fitSystemWindows="true"
编辑:我忘了提及我的 BottomSheetDialogFragment 已完全展开并且MATCH_PARENT. 也许有不同的灵魂可以在片段上获得底部工作表行为,而无需从 BottomSheetDialogFragment 扩展。