底部菜单未显示在线性布局前面

3
如何使这个BottomSheet在前面而不是在下面。 BottomSheet放置在根LinearLayout下的Coordinator Layout中。
由于Stackoverflow不允许我添加更多代码,我会添加截图。 感谢任何帮助。 Bottom Sheet does not swipes up and stays under 这是我的bottomsheet 我的主活动xml看起来像这样:
<?xml version="1.0" encoding="utf-8"?>    
<LinearLayout android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/backgroudColor"
    xmlns:android="http://schemas.android.com/apk/res/android">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="150sp"
            android:background="@color/colorAccent"
            android:id="@+id/relative">

            <TextView
                android:id="@+id/date"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:paddingLeft="30dp"
                android:paddingRight="15dp"
                android:text="30"
                android:textSize="62sp"

                />

            <TextView
                android:id="@+id/weekDay"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Monday"
                android:textSize="26sp"
                android:layout_toRightOf="@+id/date"
                android:layout_alignTop="@+id/date"
                android:paddingTop="10dp"

                />

            <TextView
                android:id="@+id/dateMonthYear"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="January 2016"
                android:layout_toRightOf="@+id/date"
                android:layout_marginTop="70dp"
                android:paddingTop="5dp"
                />


        </RelativeLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:background="#e74c3c"
            android:id="@+id/fajar">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Fajar"
                android:layout_gravity="center_vertical"
                android:textSize="26sp"
                android:paddingStart="10dp"
                />

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:background="#2ecc71"
            android:id="@+id/zuhar">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Zuhar"
                android:layout_gravity="center_vertical"
                android:textSize="26sp"
                android:paddingStart="10dp"
                />

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:background="#3498db"
            android:id="@+id/asar">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Asar"
                android:layout_gravity="center_vertical"
                android:textSize="26sp"
                android:paddingStart="10dp"
                />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:background="#9b59b6"
            android:id="@+id/maghrib">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Maghrib"
                android:layout_gravity="center_vertical"
                android:textSize="26sp"
                android:paddingStart="10dp"
                />

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:background="#f1c40f"
            android:id="@+id/isha">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Isha"
                android:layout_gravity="center_vertical"
                android:textSize="26sp"
                android:paddingStart="10dp"/>


        </LinearLayout>

        <android.support.design.widget.CoordinatorLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/backgroudColor">

            <include layout="@layout/bottomsheet"/>

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

</LinearLayout>

这是因为线性布局方向为垂直。尝试使用相对布局或将滚动视图设置为父布局,以查看xml中底部工作表的位置。 - yashkal
请查看此文章- https://medium.com/android-bits/android-bottom-sheet-30284293f066 - D_Alpha
@Lucky 感谢您的回答。由于项目(5)是固定的,我真的需要使用ScrollView吗?我该如何在RelativeLayout中实现相同的结果?它允许将LinearLayout嵌套在父RelativeLayout中吗?谢谢! - Ameer Hamza
2个回答

2
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/app_background"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="150sp"
            android:background="@color/colorAccent"
            android:id="@+id/relative">

            <TextView
                android:id="@+id/date"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:paddingLeft="30dp"
                android:paddingRight="15dp"
                android:text="30"
                android:textSize="62sp"/>

            <TextView
                android:id="@+id/weekDay"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Monday"
                android:textSize="26sp"
                android:layout_toRightOf="@+id/date"
                android:layout_alignTop="@+id/date"
                android:paddingTop="10dp"/>

            <TextView
                android:id="@+id/dateMonthYear"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="January 2016"
                android:layout_toRightOf="@+id/date"
                android:layout_marginTop="70dp"
                android:paddingTop="5dp"/>

        </RelativeLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:background="#e74c3c"
            android:id="@+id/fajar">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Fajar"
                android:layout_gravity="center_vertical"
                android:textSize="26sp"
                android:paddingStart="10dp"
                android:paddingLeft="10dp" />

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:background="#2ecc71"
            android:id="@+id/zuhar">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Zuhar"
                android:layout_gravity="center_vertical"
                android:textSize="26sp"
                android:paddingLeft="10dp"/>

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:background="#3498db"
            android:id="@+id/asar">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Asar"
                android:layout_gravity="center_vertical"
                android:textSize="26sp"
                android:paddingLeft="10dp"/>
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:background="#9b59b6"
            android:id="@+id/maghrib">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Maghrib"
                android:layout_gravity="center_vertical"
                android:textSize="26sp"
                android:paddingLeft="10dp"/>

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:background="#f1c40f"
            android:id="@+id/isha">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Isha"
                android:layout_gravity="center_vertical"
                android:textSize="26sp"
                android:paddingLeft="10dp"/>

        </LinearLayout>
    </LinearLayout>

    <include layout="@layout/bottomsheet"/>

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

请尝试此xml代码,重要的是不要忘记将layout_behavior属性添加到bottomsheet.xml中。

1
你可以尝试

android:elevation="1dp"

将内容布局的XML添加到底部表单中。

完全没有视觉差异 - Ameer Hamza
我已经尝试了高度,它完全正常运行。如果您已经给任何父布局提供了高度,请尝试增加高度。 - Pratim P

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接