我正在尝试创建一个类似于下面这样的警报。我已经用ediitext替换了图像中的文本。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:orientation="vertical">
<LinearLayout
android:layout_marginTop="20dp"
android:background="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_marginTop="-20dp"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_gravity="center"
android:src="@drawable/ic_bell"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="@drawable/border"
android:gravity="top|left"
android:inputType="textMultiLine"
android:lines="8"
android:maxLines="10"
android:minLines="6"
android:scrollbars="vertical"/>
</LinearLayout>
<LinearLayout
android:background="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:weightSum="2">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/colorPrimary"
android:text="Submit"
android:textColor="@color/white"/>
<View
android:layout_width="4dp"
android:layout_height="match_parent"
android:background="@android:color/transparent"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/colorPrimary"
android:text="Cancel"
android:textColor="@color/white"/>
</LinearLayout>
</LinearLayout>
我已将根布局设置为透明,并使其子项具有白色背景。我将 ImageView 的 marginTop 设置为 -20,以便它向上突出,但我无法获得相同的效果。为什么呢?