zoukankan      html  css  js  c++  java
  • 利用半透明对话框实现新浪微博android客户端首次运行时的提示界面

    文章出处:http://blog.csdn.net/sunmanzth/article/details/6902458


    首先,设置要覆盖在最上方的dialog的view

    [html] view plaincopy
     
    1. <?xml version="1.0" encoding="utf-8"?>  
    2. <RelativeLayout android:background="@drawable/navigater_bg" android:padding="0.0dip" android:layout_width="fill_parent" android:layout_height="fill_parent"  
    3.   xmlns:android="http://schemas.android.com/apk/res/android">  
    4.     <ImageView android:id="@id/ivNavigater_top" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/navigater_top" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" />  
    5.     <ImageView android:id="@id/ivNavigater_center" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/navigater_center" android:layout_centerInParent="true" />  
    6.     <ImageView android:id="@id/ivNavigater_clickable" android:padding="0.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="0.0dip" android:src="@drawable/navigater_clickable" android:layout_alignParentRight="true" android:layout_alignParentBottom="true" />  
    7.     <ImageView android:id="@id/ivNavigater_bottom" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="0.0dip" android:src="@drawable/navigater_bottom" android:adjustViewBounds="true" android:layout_alignParentLeft="true" android:layout_alignParentBottom="true" />  
    8. </RelativeLayout>  


    然后,在values/styles.xml添加style for 半透明:

    [html] view plaincopy
     
    1. <style name="Dialog_Fullscreen">  
    2.     <item name="android:windowBackground">@android:color/transparent</item>  
    3.     <item name="android:windowNoTitle">true</item>  
    4.     <item name="android:windowIsTranslucent">true</item>  
    5.     <item name="android:windowContentOverlay">@null</item>  
    6.     <item name="android:windowAnimationStyle">@style/Dialog_Anim</item>  
    7.     <item name="android:colorBackgroundCacheHint">@null</item>  
    8. </style>  


    继续添加style for 淡入淡出效果:

    [html] view plaincopy
     
    1. <style name="Dialog_Anim">  
    2.     <item name="android:windowEnterAnimation">@anim/fading_in</item>  
    3.     <item name="android:windowExitAnimation">@anim/fading_out</item>  
    4. </style>  

    在anim文件夹下,添加文件fading_in.xml for 淡入

    [html] view plaincopy
     
    1. <?xml version="1.0" encoding="utf-8"?>  
    2. <set  
    3.   xmlns:android="http://schemas.android.com/apk/res/android">  
    4.     <alpha android:duration="500" android:fromAlpha="0.1" android:toAlpha="1.0" />  
    5. </set>  


    添加文件fading_out.xml for 淡出

    [html] view plaincopy
     
    1. <?xml version="1.0" encoding="utf-8"?>  
    2. <set  
    3.   xmlns:android="http://schemas.android.com/apk/res/android">  
    4.     <alpha android:duration="500" android:fromAlpha="0.1" android:toAlpha="1.0" />  
    5. </set>  


    最后,在要弹出对话框的地方添加如下代码:

    [java] view plaincopy
     
    1.       Dialog dialog = new Dialog(this, R.style.Dialog_Fullscreen);          
    2.       dialog.setContentView(R.layout.sina);  
    3.       ImageView iv = (ImageView)dialog.findViewById(R.id.ivNavigater_clickable);  
    4.       iv.setOnClickListener(new OnClickListener() {  
    5.       
    6.     @Override  
    7.     public void onClick(View v) {  
    8.         dialog.dismiss();  
    9.     }  
    10. });  
    11.       dialog.show();  



    最终效果如图:


    参考:

              http://mingkg21.iteye.com/blog/513397

  • 相关阅读:
    20200917-2 词频统计
    20200910-2 博客作业
    20200910-1 每周例行报告
    20200910-3命令行和控制台编程
    使用Requests库实现api接口测试(Python)
    Python Lambda函数的几种使用方法
    文本与向量之间的转换
    Oracle连接出现error: ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
    一图看懂新一代人工智能知识体系大全
    SqlDeveloper连接MySQL出现The connection property ‘zeroDateTimeBehavior’ acceptable values are: ‘CONVERT_TO_NULL’, ‘EXCEPTION’ or ‘ROUND’. The value ‘convertToNull’ is not acceptable 错误
  • 原文地址:https://www.cnblogs.com/jiezzy/p/2673229.html
Copyright © 2011-2022 走看看