<分区>
如标题所述,我正在尝试将 CardView 放入 ScrollView 中,但 CardView 高度阴影被其父项关闭...
这是布局 XML:
<FrameLayout
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"
tools:context=".TestScrollViewActivity">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="128dp"
android:background="?colorPrimary"
android:gravity="bottom"
android:minHeight="?actionBarSize"/>
<ScrollView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:clipToPadding="false"
android:paddingBottom="40dp"
android:paddingTop="60dp">
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="4dp"
app:cardBackgroundColor="@android:color/white"
app:cardCornerRadius="0dp">
<LinearLayout
android:layout_width="400dp"
android:layout_height="600dp"
android:orientation="vertical">
</LinearLayout>
</android.support.v7.widget.CardView>
</ScrollView>
</FrameLayout>
我发现的唯一解决方法是向父 ScrollView 添加填充或向子 CardView 添加边距...
是否有任何选项可以在不使用填充/边距的情况下防止这种情况发生?
谢谢。
编辑:
这是在父 ScrollView 上没有设置填充的情况下布局的样子,可以看到,左右阴影被切断了:
现在,如果将填充添加到父 ScrollView 的边,阴影将被正确绘制,如下所示:
所以,我的主要问题是这是实现该目标的唯一方法?还是父 View 上有标签或配置允许正确绘制其 subview ?