Reputation: 539
I would like to ask someone on how to add shadow on android dialog?
Is there a way to do this thing? Because currently i have a dialog box but it is plane and no shadow style.
Hope someone can help me.
Here is my activity_dialog.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:context="com.bloxofcode.toggle.MainActivity">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:background="@color/colorHeaderDialog"
android:textColor="@android:color/white"
android:text="@string/select_gender"
android:paddingLeft="5dp"
android:paddingTop="15dp"
android:paddingBottom="15dp"
android:gravity="center_horizontal|left"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="5dp">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="15sp"
android:hint="@string/hint_name"
android:id="@+id/editText"
android:paddingLeft="10dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ToggleButton
android:text="ToggleButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/toggleButtonMale"
android:textOn=""
android:textOff=""
android:focusable="false"
android:background="@drawable/check_male"
android:layout_weight="1" />
<ToggleButton
android:text="ToggleButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/toggleButtonFemale"
android:textOn=""
android:textOff=""
android:focusable="false"
android:background="@drawable/check_male"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="5dp">
<Button
android:id="@+id/btnCancel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Cancel"
android:textSize="10dp"
android:padding="15dp"
android:textColor="@android:color/white"
android:layout_weight="1"/>
<Button
android:id="@+id/btnAccept"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Accept"
android:textSize="10dp"
android:padding="15dp"
android:background="@color/colorDialogOK"
android:textColor="@android:color/white"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Upvotes: 3
Views: 1821
Reputation: 4524
Try this:
define new theme
<style name="dialog_theme">
...
<item name="android:windowBackground">@android:drawable/abc_menu_dropdown_panel_holo_light</item>
...
</style>
then assign this theme to your dialog:
Dialog dialog = new Dialog(this, R.style.dialog_theme);
if that drawable didn't work try this one:
android:background="@android:drawable/dialog_holo_light_frame"
hope this woks.
Upvotes: 1
Reputation: 539
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:background="@android:drawable/dialog_holo_light_frame"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.bloxofcode.teststyle.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
</RelativeLayout>
Upvotes: 0