package com.example.dialog_1;import android.app.Activity;import android.app.AlertDialog;import android.content.DialogInterface;import android.os.Bundle;import android.os.Handler;import android.view.ContextThemeWrapper;import android.widget.Toast;public class MainActivity extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);// ///弹出是否添加城市的 对话框ContextThemeWrapper contextThemeWrapper =new ContextThemeWrapper(MainActivity.this, R.style.dialog);final AlertDialog alert = new AlertDialog.Builder(contextThemeWrapper).create();alert.setTitle("悟空提示");alert.setMessage("您是第8位用户");alert.setButton(DialogInterface.BUTTON_POSITIVE, "确定", new android.content.DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface dialog, int which) {// TODO 自动生成的方法存根Toast.makeText(MainActivity.this, "您点击的确定", Toast.LENGTH_SHORT).show();}});alert.setButton(DialogInterface.BUTTON_NEGATIVE, "取消", new android.content.DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface dialog, int which) {// TODO 自动生成的方法存根Toast.makeText(MainActivity.this, "您点击的取消", Toast.LENGTH_SHORT).show();}});alert.show();new Handler().postDelayed(new Runnable() {@Overridepublic void run() {///alert.dismiss();}}, 2000);}// //onCreate}
<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="match_parent"    tools:context="${relativePackage}.${activityClass}" >    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="@string/hello_world" /></RelativeLayout>

styles.xml

<resources>    <!--        Base application theme, dependent on API level. This theme is replaced        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.    -->    <style name="AppBaseTheme" parent="android:Theme.Light">        <!--            Theme customizations available in newer API levels can go in            res/values-vXX/styles.xml, while customizations related to            backward-compatibility can go here.        -->    </style>    <!-- Application theme. -->    <style name="AppTheme" parent="AppBaseTheme">        <!-- All customizations that are NOT specific to a particular API-level can go here. -->    </style>    <style name="dialog" parent="@android:style/Theme.Dialog">        <item name="android:textSize">20sp</item>    </style></resources>
比原生的美观很多,但是后面字体并没有变大,在改变 <item name="android:textSize">20sp</item>时。


更多相关文章

  1. android 对话框大全
  2. Android(安卓)菜单栏菜单功能
  3. android 对话框大全
  4. Android(安卓)弹出对话框Dialog
  5. android图像变为黑白
  6. Android之警告对话框alertdialog
  7. android两种方法操作Sqlite数据库
  8. Android震动---启动、循环、取消控制
  9. Android(安卓)Dialog对话框的七种形式的使用

随机推荐

  1. Android中文翻译组
  2. Ubuntu下Android(安卓)NDK的安装及配置
  3. Activity之间传递类对象
  4. AndroidManifest.xml配置文件详解
  5. android的shader渲染器
  6. Android执行linux外部命令
  7. android studio教程-创建第一个项目Hello
  8. 使用Android中的Parcelable序列化对象
  9. Java乔晓松-android中上传图片到服务器To
  10. Android(安卓)apk反编译