布局视图总是结束
Layout view keep always over
我在实施工具栏时遇到了棒棒糖和棒棒糖前设备的一些问题。阴影没有显示,所以我看到最常见的获取阴影的方法是添加一个带有渐变的视图。
这是我的布局:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/container_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
</LinearLayout>
<FrameLayout
android:id="@+id/container_body"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<View
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="@drawable/toolbar_dropshadow" />
</FrameLayout>
</LinearLayout>
其中 toolbar_dropshadow 是:
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="@android:color/transparent"
android:endColor="#88333333"
android:angle="90"/>
</shape>
这种方式在大多数情况下都能很好地显示出阴影,但很少有隐藏阴影的情况。在 1 个片段中,我在工具栏正下方有一个地图 (Googlemap),所以当它更新时,阴影消失了。另外,在其他片段中,我在工具栏下方有一个图像视图,当加载图像时阴影消失。
那么,有没有一种方法可以让阴影视图始终位于顶部,即使以编程方式更新了片段?
尝试使用 RelativeLayout,以便工具栏绘制在层次结构中的其他视图之上
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/container_body"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_below="@+id/container_toolbar"
android:layout_weight="1">
<View
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="@drawable/toolbar_dropshadow" />
</FrameLayout>
<LinearLayout
android:id="@+id/container_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
</LinearLayout>
</RelativeLayout>
我在实施工具栏时遇到了棒棒糖和棒棒糖前设备的一些问题。阴影没有显示,所以我看到最常见的获取阴影的方法是添加一个带有渐变的视图。
这是我的布局:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/container_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
</LinearLayout>
<FrameLayout
android:id="@+id/container_body"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<View
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="@drawable/toolbar_dropshadow" />
</FrameLayout>
</LinearLayout>
其中 toolbar_dropshadow 是:
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="@android:color/transparent"
android:endColor="#88333333"
android:angle="90"/>
</shape>
这种方式在大多数情况下都能很好地显示出阴影,但很少有隐藏阴影的情况。在 1 个片段中,我在工具栏正下方有一个地图 (Googlemap),所以当它更新时,阴影消失了。另外,在其他片段中,我在工具栏下方有一个图像视图,当加载图像时阴影消失。
那么,有没有一种方法可以让阴影视图始终位于顶部,即使以编程方式更新了片段?
尝试使用 RelativeLayout,以便工具栏绘制在层次结构中的其他视图之上
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/container_body"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_below="@+id/container_toolbar"
android:layout_weight="1">
<View
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="@drawable/toolbar_dropshadow" />
</FrameLayout>
<LinearLayout
android:id="@+id/container_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
</LinearLayout>
</RelativeLayout>