【发布时间】:2020-04-21 13:47:55
【问题描述】:
我在这个布局上遇到了很多麻烦。
基本上我有 2 条直线,一条略带灰色,底部有阴影,另一条直线下方为白色。我的麻烦是将阴影添加到第一个线性的末尾。我尝试了“高程”,但这就是我现在需要的,因为如果最后 10dp 来自不同的颜色,我希望阴影在线性内,但我没有做对。
到目前为止,这是我的布局,我想在第一个线性视图中放置一个视图,但效果不佳。
任何想法如何做到这一点?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical"
android:layout_width="match_parent"
android:background="#f8f8f8"
android:layout_height="0dp">
<android.support.v7.widget.CardView
app:cardCornerRadius="10dp"
app:cardElevation="10dp"
android:layout_width="312dp"
android:layout_height="204dp"
app:cardBackgroundColor="@android:color/holo_red_light"/>
</LinearLayout>
<LinearLayout
android:background="#ffffff"
android:layout_weight="1"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="0dp">
</LinearLayout>
</LinearLayout>
【问题讨论】: