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

  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>

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

    <style name="Dialog_Fullscreen">
        <item name="android:windowBackground">@android :color/transparent</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowAnimationStyle">@style/Dialog_Anim</item>
        <item name="android:colorBackgroundCacheHint">@null</item>
    </style>

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

  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>

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

  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>

Five.添加文件fading_out.xml for 淡出

  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>

 

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

  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. @Override

  6. public void onClick(View v) {

  7. dialog.dismiss();

  8. }

  9. });

  10. dialog.show();

 利用半透明对话框实现新浪微博android客户端首次运行时的提示界面_android