Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> 仿QQ注冊圓形進度對話框

仿QQ注冊圓形進度對話框

編輯:關於Android編程

1、styles.xml

     <style name="dialog" parent="@android:style/Theme.Dialog">
        <item name="android:windowIsFloating">true</item>
        <!-- 設置未浮動窗口 -->
        <item name="android:windowFrame">@null</item>
        <!-- 設置無邊框 -->
        <item name="android:windowNoTitle">true</item>
        <!-- 設置無標題 -->
        <item name="android:windowBackground">@color/sc_transparent</item>
        <!-- 設置完全透明 -->
        <item name="android:backgroundDimEnabled">true</item>
        <!-- 設置屏幕變暗 -->
    </style>

 

<color name="sc_transparent">#00ffffff</color>

2.dialog_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:gravity="center_horizontal"
    android:background="@drawable/shape_dialog"
    android:paddingTop="15dp"
    android:paddingBottom="15dp"
    android:paddingLeft="30dp"
    android:paddingRight="30dp">

        
    <ProgressBar
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
             android:indeterminateDrawable="@drawable/progressbar"/>
   
         <TextView
             android:id="@+id/tvLoad"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:paddingTop="5dp"
             android:textSize="20.0sp"
             android:textColor="#ffffffff" />
    

</LinearLayout>

drawable中shape_dialog.xml

<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="rectangle"
  xmlns:android="http://schemas.android.com/apk/res/android">
    <corners android:radius="8.0dip"/>
    <solid android:color="#ff333333"/>
</shape>

progressbar.xml

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
        android:pivotX="50%" android:pivotY="50%"
        android:fromDegrees="0" android:toDegrees="360">
    <shape
        android:shape="ring"
        android:innerRadiusRatio="3"
        android:thicknessRatio="8"
        android:useLevel="false">
    <gradient
                android:type="sweep"
                android:useLevel="false"
                android:startColor="#ffffffff"
                android:centerColor="#ff808080"  
                android:centerY="0.45"
                android:endColor="#ff000000"/>
    </shape>
</rotate>

方法:

public static Dialog creatRequestDialog(final Context context, String tip) {

  final Dialog dialog = new Dialog(context, R.style.dialog);
  dialog.setContentView(R.layout.dialog_layout);
  Window window = dialog.getWindow();  
  WindowManager.LayoutParams lp = window.getAttributes();
  int width = CommonUtils.getScreenWidth(context);
  //lp.width = (int) (0.6 * width); www.2cto.com

  TextView titleTxtv = (TextView) dialog.findViewById(R.id.tvLoad);
 
  titleTxtv.setText(tip);
  return dialog;
 }

  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved