Reputation: 1591
i have made a simple dialog activity in android for learning purpose and make a custom dialogbox and shown in another activity all is going well ,the only problem is background image i have put doesn't shown in whole Dialogbox background..but it also show a white background as a corner,Here i have put a screen so that my problem will be clear..!
my image:
My code is:
dialog.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#00000000"
android:gravity="center"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:background="@drawable/bg_dilog"
android:orientation="vertical" >
<ImageView
android:id="@+id/dialog_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="@drawable/btn_close_38" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="20dp"
android:paddingLeft="30dp"
android:paddingRight="30dp" >
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Login"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#202425" />
<Button
android:id="@+id/usernm"
android:layout_width="wrap_content"
android:layout_height="32dp"
android:layout_marginTop="5dp"
android:background="@drawable/text_box"
android:gravity="center"
android:hint="Please enter your client number"
android:textSize="12dp" />
<Button
android:id="@+id/pwd"
android:layout_width="wrap_content"
android:layout_height="31dp"
android:layout_marginTop="5dp"
android:background="@drawable/text_box"
android:gravity="center"
android:hint="Please password"
android:padding="5dp"
android:textSize="12dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:textColor="#6e6d6c"
android:layout_marginTop="7dp"
android:text="Remember me" />
<ImageView
android:id="@+id/chk_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:background="@drawable/checkbox"
android:textColor="#000000" />
</LinearLayout>
<Button
android:id="@+id/login"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="5dp"
android:background="@drawable/btn_small"
android:gravity="center"
android:text="Login"
android:textColor="#f6f1eb"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Upvotes: 1
Views: 1819
Reputation: 4082
try to add style on your res/values/styles.xml
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AlertDialogCustom" parent="@android:style/Theme.Holo.Light.Panel">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">true</item>
</style>
</resources>
and apply these style to your dialog like below code:
final Dialog dialog = new Dialog(HomePage.this, R.style.AlertDialogCustom);
dialog.setContentView(R.layout.popupaddcustomer);
dialog.show();
Upvotes: 2
Reputation: 2138
Try to call in your dialog constructor:
getWindow().setBackgroundDrawableResource(android.R.color.transparent);
Upvotes: 3