1. 在Android做界面时要弹出对话框让用户输入内容,经常遇到开始的时候没有内容对话框一点点,看起来很别扭,查了下资料,修改对话框的WindowManager.LayoutParams可以达到修改对话框大小的目的。

    从Dialog继承一个自定义对话框类,在其构造函数中加上如下代码:
    WindowManagerm=getWindowManager();
  2. Displayd=m.getDefaultDisplay();//为获取屏幕宽、高
  3. LayoutParamsp=getWindow().getAttributes();//获取对话框当前的参数值
  4. p.height=(int)(d.getHeight()*0.6);//高度设置为屏幕的0.6
  5. p.width=(int)(d.getWidth()*0.95);//宽度设置为屏幕的0.95
  6. getWindow().setAttributes(p);//设置生效

更多相关文章

  1. Android使用getIdentifier()方法根据资源名来获取资源id
  2. android MediaRecorder实现录屏时带录音功能
  3. Android获取app应用程序大小的方法
  4. Android(安卓)Configuration系统设置
  5. Android(安卓)对话框 (二)ProgressDialog
  6. Android应用程序的获取,安装。
  7. Android如何获取手机各项信息
  8. android httpclient 302自动跳转
  9. android 获取手机内存大小

随机推荐

  1. android 对文件的操作模式
  2. android 利用TrafficStats类获取本应用的
  3. AndroidのCountDownTimer倒计时器
  4. Android:软件卸载的另一种方法adb uninst
  5. mtk android 配置mcp
  6. android:获取已经安装软件列表
  7. Android WIFI热点默认SSID的修改方法
  8. android 屏幕保持唤醒 不锁屏 android.pe
  9. Android之Menu菜单 onCreateOptionsMenu
  10. 将keras或tensorflow模型迁移到android端