毕业论文开发语言企业开发JAVA技术.NET技术WEB开发Linux/Unix数据库技术Windows平台移动平台嵌入式论文范文英语论文
您现在的位置: 毕业论文 >> 移动平台 >> 正文

AlertDialog对话框大小如何设置

更新时间:2013-11-22:  来源:毕业论文

private void show_menu_dlg()     {         //加载对话框资源界面         LayoutInflater factory = LayoutInflater.from(this.getContext());         final View dlgview = factory.inflate(R.layout.player_menu, null);                   AlertDialog.Builder dlg_login = new AlertDialog.Builder(this.getContext());         //将对话框布局设置到视图         dlg_login.setView(dlgview);                           //创建 并显示对话框         AlertDialog dlg = dlg_login.create();         //设置对话框位置         LayoutParams lp = dlg.getWindow().getAttributes();         //dlg.getWindow().setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);         lp.x = m_screen_width - 64;         lp.width = 64;         dlg.getWindow().setAttributes(lp);         dlg.setCanceledOnTouchOutside(true);         dlg.show();         }


布局文件:

XML/HTML code?123456789101112131415161718192021222324252627282930313233343536373839404142 <?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="#000000"    android:orientation="vertical" >       <ImageButton        android:id="@+id/playermenu_previous"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_margin="5dp"        android:padding="0dp"        android:src="@drawable/up" />       <ImageButton        android:id="@+id/playermenu_mode"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_margin="5dp"        android:padding="0dp"        android:src="@drawable/play" />       <ImageButton        android:id="@+id/playermenu_next"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_margin="5dp"        android:padding="0dp"        android:src="@drawable/down" />       <ImageButton        android:id="@+id/playermenu_relogin"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_margin="5dp"        android:padding="0dp"        android:src="@drawable/relogin" /> "   </LinearLayout>
用弹出框模拟菜单,显示在右侧边

 

private void show_menu_dlg()     {         //加载对话框资源界面         LayoutInflater factory = LayoutInflater.from(this.getContext());         final View dlgview = factory.inflate(R.layout.player_menu, null);                   AlertDialog.Builder dlg_login = new AlertDialog.Builder(this.getContext());         //将对话框布局设置到视图         dlg_login.setView(dlgview);                           //创建 并显示对话框         AlertDialog dlg = dlg_login.create();         dlg.show();         //设置对话框位置         LayoutParams lp = dlg.getWindow().getAttributes();         //dlg.getWindow().setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);         lp.x = m_screen_width - 64;         lp.width = 64;         dlg.getWindow().setAttributes(lp);         dlg.setCanceledOnTouchOutside(true);         }

设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优尔论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。