1.首先在资源里面建立style的value;

<!-- ShareDialog --> <style name="Theme.ShareDialog" parent="android:style/Theme.Dialog"><item name="android:windowBackground">@drawable/fill_box</item><item name="android:windowNoTitle">true</item></style>

2. drawable/filled_box.xml:

<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android"><shape><stroke android:width="3dp" /><corners android:radius="3dp" /><padding android:left="10dp" android:top="10dp" android:right="10dp"android:bottom="10dp" /></shape><item android:drawable="@drawable/dialog_my_bg" /></selector>

3.方法:

public static Dialog getDialog(final Context context, final String name) {        final Dialog dialog = new Dialog(context, R.style.Theme_ShareDialog);        dialog.setContentView(R.layout.dialog_share_comment);        Button btnshare = (Button) dialog.findViewById(R.id.dialog_btn_ok);        btnshare.setOnClickListener(new Button.OnClickListener() {            public void onClick(View view) {            }        });        return dialog;    }
其中 dialog.setContentView(R.layout.dialog_share_comment);是对话框的布局

new Dialog(context, R.style.Theme_ShareDialog);引用style

4.调用

  public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.article_row);        getDialog(this, "Hie").show();    }


更多相关文章

  1. android 对话框显示工具类
  2. 敏捷软件测试的七个关键成功要素 Android设备到底侵犯了微软的什
  3. android 时间,日期对话框
  4. Android Checkbox在对话框中显示
  5. Android 设置对话框中的确定按钮的 enabled 属性
  6. android 系统提示对话框(AlertDialog)的使用
  7. Android消息提示框和对话框的使用

随机推荐

  1. Android数字证书
  2. Android四大组件之Activity
  3. android 各版本发布时间
  4. Android日志工具
  5. Android(安卓)一些注意
  6. 避免在Android上冷启动
  7. 探索Android中的Parcel
  8. android 开发环境安装和测试中常出现的问
  9. Android读取JSON格式数据
  10. Android(安卓)Animation学习