java如何在材料设计领域创建主/细节
如何将立面添加到主视图/详图视图的详图窗格中,以便在其下方提供阴影,并将其放置在部分覆盖工具栏的位置(如下图所示)?我试着使用安卓:elevation="4dp"
,但那对我不起作用
XML布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
安卓:layout_width="match_parent"
安卓:layout_height="match_parent"
安卓:orientation="vertical">
<include layout="@layout/toolbar_singleline"/>
<LinearLayout
xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
安卓:layout_width="match_parent"
安卓:layout_height="match_parent"
安卓:baselineAligned="false"
安卓:divider="@drawable/divider_vertical"
安卓:orientation="horizontal"
安卓:showDividers="middle">
<RelativeLayout
安卓:id="@+id/master_container"
安卓:layout_width="0dp"
安卓:layout_height="match_parent"
安卓:layout_weight="1"/>
<FrameLayout
安卓:id="@+id/detail_container"
安卓:elevation="4dp"
安卓:layout_width="0dp"
安卓:layout_height="match_parent"
安卓:layout_weight="3"/>
</LinearLayout>
</LinearLayout>
主工具栏下的项目
<RelativeLayout
安卓:id="@+id/master_container"
安卓:layout_width="0dp"
安卓:layout_height="match_parent"
app:layout_constraintHorizontal_weight="2"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@+id/divider"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/masterToolbar" />
# 1 楼答案
这看起来有点复杂,尤其是考虑到搜索操作栏图标与“主”列的最右边对齐
我怀疑这在功能上是一个
FrameLayout
(或子类)持有一个水平LinearLayout
,其中“细节”窗格作为CardView
(具有0dp角半径)覆盖在其余内容上。下面是一个快速模板:![enter image description here](https://i.stack.imgur.com/gF3n7.png)
<> P>这里唯一真正的窍门是假的“DealIdBealToeToeBar”工具栏,它仅用于正确地定位主工具栏(主工具栏需要在屏幕中间结束,以便动作图标位于正确的位置)。p>