I'm looking to create a Dialog styled like the below, but I'm a little stuck. It has rounded corners and two different background colors.
It will contain multiple Textviews in a vertical setup in the end. I tried to make a vertical LinearLayout contain two children that were also vertical LinearLayout, but that did not seem to go over well.
How do you create a view like this, with two colors of background that use the same rounded corners and can contain multiple, vertical items each?
My current code looks like this. I've set a single vertical layout, which uses a rounded-corners white background with padding, and I set the red background on the first two text-views, since they need to be white-on-red. However, their backgrounds can't push out to the edges of their parent because of the padding.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="600dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/warning_dialog_background"
android:padding="20dp"
style="@style/dialog" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:background="@color/Warning"
style="@style/white"
android:text="@string/warning_block_explanation"
android:paddingBottom="30dp"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
style="@style/title.warning"
android:text="@string/warning_block_warning_title"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
style="@style/safe.title"
android:text="@string/safe_title"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
style="@style/safe"
android:text="@string/safe_text"
/>
</LinearLayout>
You can create custom layout and inflate that layout using setContentView() for dialog;
Layout for this:
drawable for same: