在新浪微博Android客户端的开发的课程中呢要用的得自定义的Dialog,这个Dialog个人觉得还不错,所以就那处理来分享了。如果有兴趣的朋友也可以观看视频,视频中会有详细的介绍(新浪微博Android客户端视频教程区)。
首先呢,还是让我们先来看效果图,正所谓有图有真相:
下面我们看看是怎么来实现的:
第一步:在res/layout目录下新创建一个布局文件:
authorize_dialog.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="15dip">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/info"
android:layout_marginLeft="10dip"
android:layout_marginTop="3dip"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="信息提示"
android:textSize="13px"
android:textColor="#219ac6"
android:layout_marginLeft="5dip"/>
</LinearLayout>
<TextView
android:id="@+id/text_info"
android:layout_marginTop="6px"
android:layout_width="200px"
android:layout_height="wrap_content"
android:textColor="#686767"
android:textSize="12px"
android:layout_marginLeft="10dip"
android:text="第一次使用需要输入您的新浪微博账号和密码进行登录授权"/>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="40px">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true">
<Button
android:id="@+id/btn_start"
android:layout_width="83px"
android:layout_height="38px"
android:background="@drawable/btn_begin_d"/>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
第二步:在res/values文件夹下创建一个Style文件:
authorize_dialog_style.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="dialog" parent="@android:style/Theme.Dialog">
<item name="android:windowFrame">@null</item><!--Dialog的windowFrame框为无 -->
<item name="android:windowIsFloating">true</item><!--是否浮现在activity之上 -->
<item name="android:windowIsTranslucent">false</item> <!-- 是否半透明 -->
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@drawable/dia_bg</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
</resources>
通过以上两步,我们就完成了一个Android中的漂亮Dialog啦,那下面我们再来看看这个漂亮Dialog是如何使用的
第三步:创建一个Activity,在Activity中的onCreate 方法中加入一下代码:
View diaView=View.inflate(this, R.layout.dialog, null);
dialog=new Dialog(AuthorizeActivity.this,R.style.dialog);
dialog.setContentView(diaView);
dialog.show();
到此为止,一个漂亮的Dialog就搞定了。如还需了解更详细的讲解,请观看新浪微博Android客户端的开发视频,地址是在:(新浪微博Android客户端视频教程区)。
http://bbs.droidstouch.com/thread-80-1-1.html
分享到:
相关推荐
android-dialog弹出框,弹出gridview条目选中,本人亲测,可以使用,放心下载吧!!
Android 利用dialog弹出 二级下拉列表 ExpandableListView+DialogLI。 利用dialog和ExpandableListView实现的一个弹出二级菜单项,并进行了封装,可在activity和fragment中随意调用。简单实用,兼容性好。 二级列表
做了一个android带小三角的弹出框,就是右上角有个小三角形,整体比较美观,代码精简没有多余,功能到位,具体大家下载下来自己看吧
各种android弹出dialog效果以及各种dialog样式各种android弹出dialog效果以及各种dialog样式各种android弹出dialog效果以及各种dialog样式各种android弹出dialog效果以及各种dialog样式各种android弹出dialog效果...
自定义dialog弹出框,通过shape和seleter自定义出自己想要的样式。还有弹出的动画,从不同方向弹出和效果。
很好用的Dialog弹出框,给出demo,用起来很简单
jquery Dialog 弹出框 上一个项目就是用的这个 很漂亮很实用
底部弹出dialog 添加简单的进入 退出动画
这个Demo 是我自己在工作中接触到的Dialog 的一个合集
Two Step Picker Dialog For Android Description Two step picker dialog for Android that helps you easily pick nested data on android. Usage To use two step picker dialog you must add it as a ...
最近做android项目的时候,因为系统自带的dialog实在不美观,所以我自定义了比较美观的dialog。而且有圆角和圆形头像,圆角给人柔和的感觉,dialog顶部是个半圆,所以十分美观。说起dialog,没什么代码量,主要工作...
在Android中经常会遇到需要使用Dialog风格弹出框的activity,首先我们可能会首先想到的是在XML布局文件中设置android:layout_height=”wrap_content”属性,让activity的高度自适应,显然这还不行,我们还需要为其...
一个Android登录界面的制作范例,以Android dialog方式实现的弹出式登录框,并包括了帐号密码保存、加密算法等模块源码。本登录源码将对密码信息进行AES加密算法加密后保存,有些功能需要服务器配合才能看到,比如...
Dialog风格弹出框的Activity
androidDialog弹出工具类 - DialogUtil.java 封装了很多种常用类型的Dialog
使用Dialog实现从页面顶部弹出对话框,使用场景:搜索等
Android 自定义单选、多选对话框及popwindow窗口实例源码
主要为大家详细介绍了Android自定义底部弹出框ButtomDialog,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
android 全屏弹出dialog,底部弹入,底部弹出+弹出dialog输入法,实现了从底部弹出的输入法。自动适配手机屏幕