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

Mar*_*ios 5 android landscape-portrait bottom-sheet

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

如何让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 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:class="http://schemas.android.com/tools"
    android:id="@+id/bottomSheetLayout"
    android:layout_width="match_parent"
    android:layout_height="300dp"
    app:behavior_peekHeight="50dp"
    android:orientation="vertical"
    app:layout_behavior="@string/bottom_sheet_behavior">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="0.9"
        android:weightSum="4">

        <ImageButton
            android:id="@+id/category0"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="#BB45BBEC"
            android:onClick="jumpto0"
            />

        <ImageButton
            android:id="@+id/category1"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:textAllCaps="false"
            android:layout_weight="1"
            android:background="#AAA"
            android:onClick="jumpto1"
            />

        <ImageButton
            android:id="@+id/category2"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="#FFEF53"
            android:onClick="jumpto2"
            />
        <ImageButton
            android:id="@+id/category3"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="#FFF50E0E"
            android:onClick="jumptp3"
            />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="0.2">

        <ImageButton
            android:id="@+id/bottom1"
            android:layout_width="98dp"
            android:layout_height="62dp"
            android:layout_gravity="center"
            android:background="#FFF50E0E"
            />

        <ImageButton
            android:id="@+id/bottom2"
            android:layout_width="98dp"
            android:layout_height="62dp"
            android:layout_gravity="center"
            android:background="#FFF5"
            />

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

War*_*ble 1

在这种情况下,您可以使用RightSheetBehavior。但首先,您应该处理方向变化并根据方向替换行为。