小编Mar*_*ios的帖子

更改底部工作表在横向中的位置:"边工作表"

这是这里提出的问题的扩展:

如何让bottomSheet从顶部打开?

Android"Top Sheet"相当于"Bottom Sheet"?

当然,"Bottom Sheet"之所以被称为是因为你可以从底部滑动它.

我在我的设计中发现,这在肖像模式下非常有效(图1和图2),但在横向模式下,我想更好地利用(更多可见性)"主要区域"(图3).出于这个原因,我希望有一个"侧板",有点像导航抽屉(图4).

在此输入图像描述

直到现在我无法找到解决方案或替代方案,欢迎任何帮助!


下面是一个基本代码,用于演示横向模式中的问题

主要活动

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}}
Run Code Online (Sandbox Code Playgroud)

activity_main.xml中

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/container_main"
    android:orientation="vertical">

<android.support.design.widget.CoordinatorLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">


    <!-- Main Content -->
    <include layout="@layout/content_main"
        />

    <!-- Bottom Sheet Content -->
    <include layout="@layout/content_bottom_sheet"
        />

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

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

content_main.xml

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    android:weightSum="2"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:showIn="@layout/activity_main">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="0.6">
    </LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

content_bottom_sheet.xml

    <?xml …
Run Code Online (Sandbox Code Playgroud)

android landscape-portrait bottom-sheet

5
推荐指数
1
解决办法
1062
查看次数

标签 统计

android ×1

bottom-sheet ×1

landscape-portrait ×1