First on:
The layout of the title is:
<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=" @dimen/title_ Height " android:background=" @drawable/bg_top_title " ><textview android:layout_width=" Wrap_ Content " android:layout_height=" wrap_content " android:text=" Title " android:textsize=" 20sp " Android:layout_centerinparent= "true"/> <imageview android:layout_width= "@dimen/header_btn_ Width " android:layout_height=" wrap_content " android:layout_margintop=" 14DP " android:layout_ Alignparenttop= "true" android:paddingleft= "4DP" android:id= "@+id/right_button" android:src= "@ drawable/arrow_dropdown_pressed " android:layout_alignparentright=" true " /></relativelayout>
The layout of the dialog popup is
<relativelayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:tools= "http// Schemas.android.com/tools "android:layout_width=" fill_parent "android:layout_height=" fill_parent "android:id=" @+i D/dropdownbckgrnd "android:background=" @drawable/bg_pop_up_dimmer "> <imageview android:layout_width = "@dimen/header_btn_width" android:layout_height= "wrap_content" android:layout_margintop= "14DP" Andro Id:layout_alignparenttop= "true" android:paddingleft= "4DP" android:id= "@+id/right_button" android:src= "@drawable/arrow_dropdown_pressed" android:layout_alignparentright= "true"/> <linearlayout a Ndroid:layout_width= "Fill_parent" android:layout_height= "wrap_content" android:layout_gravity= "center" android:layout_marginleft= "12DP" android:layout_marginright= "12DP" android:layout_margintop= "35DP" android:orientation= "Vertical" Android: Focusable= "True" android:focusableintouchmode= "true" android:background= "@drawable/topmenu_popup_down" > <button android:layout_width= "fill_parent" android:layout_height= "45DP" Android : background= "@drawable/main_menu_button_background" android:layout_margin= "@dimen/button_margin_top" android:text= "AAA"/> <button android:layout_width= "Fill_parent" Android:la yout_height= "45DP" android:background= "@drawable/main_menu_button_background" android:layout_margin= "@dimen/button_margin_top" android:text= "bbb"/> <button Android:layout_widt H= "Fill_parent" android:layout_height= "45DP" android:background= "@drawable/main_menu_button_backgrou nd "android:layout_margin=" @dimen/button_margin_top "android:text=" CCC "/> </lin Earlayout></relatiVelayout>
We use
<span style= "White-space:pre" ></span>mdialog = new Dialog (context,r.style.customdialog); Mdialog.setcontentview (r.layout.dialog_layout);
<style name= "Customdialog" parent= "@android: Style/theme.dialog" > <item name= "Android:windownotitle" >true</item>//Set title <item name= "Android:windowbackground" > @android: color/transparent</ Item> //dialog should be transparent background <item name= "android:windowisfloating" >false</item> // Dialog is not suspended <item name= "android:layoutanimation" > @null </item> //dialog pop-up without animation </ Style>
Then we'll set the other properties of dialog
Mdialog = new Dialog (context,r.style.customdialog); Mdialog.setcontentview (r.layout.dialog_layout); Mdialog.setcanceledontouchoutside (TRUE); Windowmanager.layoutparams params = Mdialog.getwindow (). GetAttributes (); Params.gravity = gravity.top;//This setting causes the dialog to bounce from above params.windowanimations = 1; WindowManager manager = (WindowManager) context.getsystemservice (Context.window_service); Display display = Manager.getdefaultdisplay (); Windowheight= display.getheight (); Windowwidth= display.getwidth (); Params.width = WindowWidth; Params.height = WindowHeight; Mdialog.findviewbyid (R.id.right_button). Setonclicklistener (New View.onclicklistener () {@Override PU Blic void OnClick (View v) {Mdialog.dismiss (); } }); Mdialog.findviewbyid (R.ID.DROPDOWNBCKGRND). Setonclicklistener (New View.onclicklistener () {@Override public void onClick (View v) {Mdialog.dismiss (); } });