android美化对话框
来源:互联网 发布:软件接口设计工具 编辑:程序博客网 时间:2024/06/01 23:06
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>时。
0 0
- android美化对话框
- Android 带按钮对话框美化
- VC对话框美化
- 美化对话框(一)
- JS美化对话框
- MFC对话框美化
- MFC对话框界面美化
- 使用SkinMagic美化MFC对话框
- 用SkinH美化MFC对话框
- AnimateWindow 来美化你的对话框
- 对话框样式的activity实现与美化
- VS2013 MFC使用位图美化对话框
- android界面美化
- android ListView的美化
- android的控件美化
- android桌面文件夹美化
- Android中的Shape美化
- android listView 美化
- Hadoop RPC 详解(参数调优)
- 对synchronized关键字的理解
- 芒果iOS开发之git新手常用操作
- YARN RPC实现
- 《Java Web程序开发入门》知识总结(三)
- android美化对话框
- YARN RPC应用实例(1)
- 一起talk C栗子吧(第八十四回:C语言实例--使用信号进行进程间通信一)
- 未来,这4个潜在的发展机遇你知道吗?
- YARN RPC应用实例(2)
- 实习体会
- ACL权限简介与开启-linux系列32
- YARN RPC应用实例(3)
- 服务库与事件库