android创建自定义对话框
2013-07-08 14:11
246 查看
创建如下自定义对话框:
JAVA代码
R.layout.tag_dialog如下
R.style.dialog文件如下
JAVA代码
LayoutInflater li = LayoutInflater.from(TagActivity. this); //NOTE final View TestView = li.inflate(R.layout.tag_dialog, null); dialog = new Dialog(TagActivity. this, R.style.dialog); dialog.setContentView(TestView); dialog.setCancelable( true); dialog.show(); |
<?xml version= "1.0" encoding= "utf-8" ?> <LinearLayout xmlns:android= "http://schemas.android.com/apk/res/android" android:layout_width= "match_parent" android:layout_height= "match_parent" android:orientation= "vertical" > <LinearLayout android:layout_height= "wrap_content" android:layout_width= "fill_parent" > <TextView android:id= "@+id/title" android:layout_height= "wrap_content" android:layout_width= "fill_parent" android:gravity= "center" android:textColor= "@color/white" android:paddingTop= "15dp" ></TextView> </LinearLayout> <LinearLayout android:layout_width= "200dp" android:layout_height= "200dp" android:orientation= "vertical" android:paddingLeft= "10dp" android:paddingRight= "10dp" android:paddingTop= "10dp" > <EditText android:id= "@+id/name" android:layout_width= "fill_parent" android:layout_height= "wrap_content" android:background= "@color/transparent" android:textColor= "@color/white" android:hint= "输入消息内容" android:textColorHint= "@color/white" ></EditText> </LinearLayout> <LinearLayout android:layout_width= "fill_parent" android:layout_height= "wrap_content" android:orientation= "horizontal" android:layout_marginBottom= "10dp" > <RelativeLayout android:layout_width= "fill_parent" android:layout_height= "wrap_content" android:layout_weight= "1" > <ImageButton android:id= "@+id/sure" android:layout_width= "wrap_content" android:layout_height= "wrap_content" android:src= "@drawable/sure" android:background= "@drawable/btn_click_background" android:layout_centerHorizontal= "true" ></ImageButton> </RelativeLayout> <RelativeLayout android:layout_width= "fill_parent" android:layout_height= "wrap_content" android:layout_weight= "1" > <ImageButton android:id= "@+id/cancel" android:layout_width= "wrap_content" android:layout_height= "wrap_content" android:src= "@drawable/cancel" android:background= "@drawable/btn_click_background" android:layout_centerHorizontal= "true" ></ImageButton> </RelativeLayout> </LinearLayout> </LinearLayout> |
<!-- 下面是对话框对应的style --> <style name= "dialog" parent= "@android:style/Theme.Dialog" > <item name= "android:windowFrame" >@null </item> <item name= "android:windowIsFloating" >true </item> <item name= "android:windowIsTranslucent" >true </item> <item name= "android:windowNoTitle" >true </item> <!--<item name="android:background">@android:color/transparent</item>--> <item name= "android:background" >@android:color /transparent </item> <item name= "android:windowBackground" >@drawable /dialog_bg </item> <item name= "android:backgroundDimEnabled" >true </item> <item name= "android:backgroundDimAmount" >0.6 </item> <item name= "android:windowFullscreen" >true </item> </style> |
相关文章推荐
- Android学习:不再提示对话框(创建自定义对话框)
- android 创建一个简单的自定义对话框
- android创建自定义对话框
- Android 创建自定义对话框主题(使用半透明背景也不会露出原有的背景了)
- Android创建自定义视图列表对话框(数据库中的数据作为数据源,使用RecyclerView作为列表)
- Android开发中如何创建自定义对话框
- Android开发中如何创建自定义对话框
- Android开发中如何创建自定义对话框
- Android自定义对话框
- Android自定义网络加载中对话框
- Android中的普通对话框、单选对话框、多选对话框、带Icon的对话框、以及自定义Adapter和自定义View对话框详解
- Android自定义Dialog对话框
- 21种ANDROID自定义DIALOG_动画弹出对话框效果组件
- 自定义Android对话框
- InstallShield创建自定义对话框的基本方法
- Android之创建自定义属性
- Android自定义对话框(Dialog)位置,大小
- Android自定义 Dialog 对话框
- Android创建对话框的两种方式
- Android 用户自定义对话框