【发布时间】:2016-07-30 03:38:32
【问题描述】:
我正在尝试在我的布局中使用BottomSheet。
根视图是CoordinatorLayout,我想在底部工作表的顶部设置Elevation,因此我将其设置为较高的值(50dp),但是当应用程序运行时它没有显示,但它出现在 android studio设计工具。
我尝试使用纯色而不是渐变为工作表设置背景,但它仍然有效。我也尝试使用阴影形状,但它没有给出相同的高程外观。
这是我的 XML
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.atefhares.StartActivity"
android:clipToPadding="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/DetailsView"
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Details Should be shown here"
android:id="@+id/textView"
android:textSize="25sp"
android:padding="20dp" />
</LinearLayout>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.atefhares.Start_Activity" />
</LinearLayout>
<android.support.v4.widget.SlidingPaneLayout
android:id="@+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:behavior_peekHeight="70dp"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
android:background="@drawable/gradiant"
android:fillViewport="true"
android:elevation="50dp">
<include layout="@layout/bottom_sheet_layout"/>
</android.support.v4.widget.SlidingPaneLayout>
</android.support.design.widget.CoordinatorLayout>
编辑: bottom_sheet_layout.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:orientation="vertical">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="70dp"
android:background="@color/colorPrimary"
android:padding="10dp"
android:id="@+id/inviteLL">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:id="@+id/imageView"
android:background="@drawable/invite_icon"
android:layout_margin="5dp"
android:layout_gravity="center_vertical" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Invite Friends"
android:textSize="22sp"
android:textColor="#ffffff"
android:padding="10dp"
android:fontFamily="sans-serif-condensed"
android:gravity="center_vertical"
android:id="@+id/inviteTV"
android:layout_gravity="center_vertical"
android:layout_weight="1" />
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:id="@+id/arrowIV"
android:layout_gravity="center_vertical"
android:background="@drawable/arrow_up" />
</LinearLayout>
<ListView
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:id="@+id/usersLV"
android:dividerHeight="1dp"
android:divider="#ffffff"
android:background="#ffffff" />
</LinearLayout>
那么我怎样才能在Bottom Sheet上方显示立面图
有人可以帮忙吗?
【问题讨论】:
-
这里有同样的问题 :) 赞成你的问题。我可以建议您添加屏幕截图吗?还增加了赏金
-
你是用什么安卓版本的手机测试的?
-
发布您的底部工作表布局代码
-
@piotrek1543 版本 M、K、L
-
@AtefHares 我发现其他人也有同样的问题:stackoverflow.com/q/32395983/2013835 和 stackoverflow.com/q/27741567/2013835
标签: android android-coordinatorlayout elevation bottom-sheet