Paste the display first, for reference only:
The code is as follows:
1. Custom Dialog
Public class Selectdialog extends alertdialog{publicint theme) { super (context, theme);} Public Selectdialog (Context context) { super (context);} @Overrideprotectedvoid onCreate (Bundle savedinstancestate) { super.oncreate ( Savedinstancestate); Setcontentview (R.layout.slt_cnt_type);}}
2. layout file Slt_cnt_type.xml code
<?xml version="1.0"encoding="Utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="Vertical"android:padding="10DP"Android:layout_width="115DP"android:layout_height="wrap_content"Android:background="@color/blue"> <button android:layout_height="wrap_content"Android:background="#00000000"Android:layout_width="fill_parent"android:text="All Contact person"android:paddingtop="5DP"Android:paddingbottom="5DP"android:paddingleft="10DP"android:gravity="left|center_vertical"Android:id="@+id/btnsltcntall"></Button> <button android:layout_height="wrap_content"Android:background="#00000000"style="@drawable/greenhand_button"android:text="Plump Users"android:gravity="left|center_vertical"Android:paddingbottom="5DP"android:paddingtop="5DP"android:paddingleft="10DP"android:paddingright="10DP"Android:layout_width="fill_parent"Android:id="@+id/btnsltgudonguser"></Button> <button style="@drawable/greenhand_button"Android:background="#00000000"android:layout_height="wrap_content"Android:layout_width="fill_parent"android:text="Recommended Users"android:gravity="left|center_vertical"android:paddingtop="5DP"Android:paddingbottom="5DP"android:paddingleft="10DP"Android:id="@+id/btnsltrecommend"></Button></LinearLayout>
3. Color Color.xml Code
<?xml version="1.0" encoding="utf-8"? ><resources > <color name="transparent">#00000000</color></ Resources>
4. Style Style.xml Code
<?xml version="1.0"encoding="Utf-8"?><resources> <style name="Dialog"Parent="@android: Style/theme.dialog"> <item name="Android:windowframe"> @null </item><!--border-<item name="android:windowisfloating">true</item>< whether!--is on the activity--<item name="android:windowistranslucent">false</item><!--Translucent--<item name="Android:windownotitle">true</item><!--Untitled-<item Name="Android:windowbackground"> @color/transparent</item><!--Background Transparent--<item name="android:backgrounddimenabled">false</item><!--Blur--</style></resources>
4. Display dialog
Selectdialog Selectdialog =NewSelectdialog ( This, R.style.dialog);//Create dialog and set style themesWindow win =Selectdialog.getwindow (); Layoutparamsparams=Newlayoutparams ();params. x =- the;//set X coordinateparams. y =- -;//Set Y coordinateWin.setattributes (params); Selectdialog.setcanceledontouchoutside (true);//Set Click Dialog outside any area to close dialogSelectdialog.show ();
Above only for reference, if there is a problem, please put forward in time, Exchange learning!
Android custom dialog background transparent and display position settings