欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android仿微信進(jìn)度彈出框的實(shí)現(xiàn)方法

 更新時(shí)間:2017年01月04日 17:16:26   作者:rururu2211785113  
最近公司項(xiàng)目需要實(shí)現(xiàn)類似微信進(jìn)度條彈出框效果,其實(shí)現(xiàn)方法并不難,下面給大家介紹下Android仿微信進(jìn)度彈出框的實(shí)現(xiàn)方法,需要的朋友參考下吧

MainActivity:

package com.ruru.dialogproject; 
import android.app.Activity; 
import android.os.Bundle; 
import android.view.View; 
public class MainActivity extends Activity implements Runnable { 
 LoadingDialog dialog; 
 @Override 
 protected void onCreate(Bundle savedInstanceState) { 
  super.onCreate(savedInstanceState); 
  setContentView(R.layout.activity_main); 
  findViewById(R.id.btn_name).setOnClickListener(new View.OnClickListener() { 
   @Override 
   public void onClick(View view) { 
    dialog = new LoadingDialog(MainActivity.this); 
    dialog.setCanceledOnTouchOutside(false); 
    dialog.show(); 
    new Thread(MainActivity.this).start(); 
   } 
  }); 
 } 
 public void run() { 
  try { 
   Thread.sleep(5000); 
   dialog.dismiss(); 
  } catch (InterruptedException e) { 
   e.printStackTrace(); 
  } 
 } 
} 

activity_main:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
 xmlns:tools="http://schemas.android.com/tools" 
 android:id="@+id/activity_main" 
 android:layout_width="match_parent" 
 android:layout_height="match_parent" 
 tools:context="com.ruru.dialogproject.MainActivity"> 
 <Button 
  android:id="@+id/btn_name" 
  android:layout_width="match_parent" 
  android:layout_height="wrap_content" 
  android:text="Hello World!" /> 
</RelativeLayout>

LoadingDialog:

package com.ruru.dialogproject; 
import android.app.Dialog; 
import android.content.Context; 
import android.os.Bundle; 
import android.widget.LinearLayout; 
import android.widget.TextView; 
/** 
 * Created by 27c1 on 2017/1/4. 
 */ 
public class LoadingDialog extends Dialog { 
 private TextView tv; 
 /** 
  * style很關(guān)鍵 
  */ 
 public LoadingDialog(Context context) { 
  super(context, R.style.loadingDialogStyle); 
 } 
 @Override 
 protected void onCreate(Bundle savedInstanceState) { 
  super.onCreate(savedInstanceState); 
  setContentView(R.layout.dialog_loading); 
  tv = (TextView) findViewById(R.id.tv); 
  tv.setText("正在上傳....."); 
  LinearLayout linearLayout = (LinearLayout) this.findViewById(R.id.LinearLayout); 
  linearLayout.getBackground().setAlpha(210); 
 } 
} 

dialog_loading:

<?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:background="@android:color/transparent" 
 android:orientation="vertical"> 
 <LinearLayout 
  android:id="@+id/LinearLayout" 
  android:layout_width="160dp" 
  android:layout_height="160dp" 
  android:background="@drawable/yuanjiao" 
  android:gravity="center" 
  android:orientation="vertical"> 
  <ProgressBar 
   android:id="@+id/progressBar1" 
   style="?android:attr/progressBarStyleInverse" 
   android:layout_width="wrap_content" 
   android:layout_height="wrap_content" 
   android:layout_gravity="center" 
   android:background="@android:color/transparent" /> 
  <TextView 
   android:id="@+id/tv" 
   android:layout_width="wrap_content" 
   android:layout_height="wrap_content" 
   android:layout_gravity="center" 
   android:paddingTop="10dp" 
   android:textColor="#fff" /> 
 </LinearLayout> 
</LinearLayout> 

R.style.loadingDialogStyle:

<style name="loadingDialogStyle" parent="android:Theme.Dialog"> 
  <item name="android:windowBackground">@android:color/transparent</item><!--設(shè)置dialog的背景--> 
  <item name="android:windowFrame">@null</item><!--Dialog的windowFrame框?yàn)闊o(wú)--> 
  <item name="android:windowNoTitle">true</item><!--是否顯示title--> 
  <item name="android:windowIsFloating">true</item><!--是否浮現(xiàn)在activity之上--> 
  <item name="android:windowIsTranslucent">true</item><!--是否半透明--> 
  <item name="android:windowContentOverlay">@null</item><!--是否半透明--> 
  <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item><!-- 對(duì)話框是否有遮蓋 --> 
  <item name="android:backgroundDimEnabled">false</item><!--背景是否模糊顯示--> 
  <item name="android:backgroundDimAmount">0.6</item><!--背景的灰度--> 
 </style> 

drawable-yuanjiao:

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
 <solid android:color="#86222222" /> 
 <corners 
  android:bottomLeftRadius="10dp" 
  android:bottomRightRadius="10dp" 
  android:topLeftRadius="10dp" 
  android:topRightRadius="10dp" /> 
</shape>

效果:

關(guān)于樣式:

<item name="android:windowFrame">@null</item> :Dialog的windowFrame框?yàn)闊o(wú) 
<item name="android:windowIsFloating">true</item>:是否浮現(xiàn)在activity之上 
<item name="android:windowIsTranslucent">false</item>:是否半透明 
<item name="android:windowNoTitle">true</item>:是否顯示title 
<item name="android:windowBackground">@drawable/dia_bg</item>:設(shè)置dialog的背景 
<item name="android:backgroundDimEnabled">true</item>背景是否模糊顯示 
<item name="android:backgroundDimAmount">0.6</item>背景的灰度 

Window attributes屬性詳解

顏色為:#393939

以上所述是小編給大家介紹的Android仿微信進(jìn)度彈出框效果,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

  • Android錄音功能的實(shí)現(xiàn)以及踩坑實(shí)戰(zhàn)記錄

    Android錄音功能的實(shí)現(xiàn)以及踩坑實(shí)戰(zhàn)記錄

    在Android 開(kāi)發(fā)過(guò)程中,有些功能是通用的,或者是多個(gè)業(yè)務(wù)方都需要使用的,下面這篇文章主要給大家介紹了關(guān)于Android錄音功能的實(shí)現(xiàn)以及踩坑的相關(guān)資料,需要的朋友可以參考下
    2022-06-06
  • Android搭建grpc環(huán)境過(guò)程分步詳解

    Android搭建grpc環(huán)境過(guò)程分步詳解

    本篇文章使用的IDE是Android Studio。這里先吐槽一句,安卓項(xiàng)目搭建grpc環(huán)境,不管是引入插件還是引入第三方庫(kù),對(duì)于版本的要求都極為苛刻,一旦版本不匹配就會(huì)報(bào)錯(cuò),所以對(duì)于版本的搭配一定要注意
    2023-04-04
  • Android開(kāi)發(fā)之FloatingActionButton懸浮按鈕基本使用、字體、顏色用法示例

    Android開(kāi)發(fā)之FloatingActionButton懸浮按鈕基本使用、字體、顏色用法示例

    這篇文章主要介紹了Android開(kāi)發(fā)之FloatingActionButton懸浮按鈕基本使用、字體、顏色用法,結(jié)合實(shí)例形式分析了Android FloatingActionButton懸浮按鈕的基本功能、布局、使用方法及操作注意事項(xiàng),需要的朋友可以參考下
    2019-03-03
  • 實(shí)現(xiàn)輪轉(zhuǎn)廣告帶底部指示的自定義ViewPager控件

    實(shí)現(xiàn)輪轉(zhuǎn)廣告帶底部指示的自定義ViewPager控件

    在項(xiàng)目中經(jīng)常需要使用輪轉(zhuǎn)廣告的效果,在android-v4版本中提供的ViewPager是一個(gè)很好的工具,而一般我們使用Viewpager的時(shí)候,都會(huì)選擇在底部有一排指示物指示當(dāng)前顯示的是哪一個(gè)page,下面我們就做這個(gè)功能的實(shí)現(xiàn)
    2013-11-11
  • Android手機(jī)鬧鐘用法實(shí)例

    Android手機(jī)鬧鐘用法實(shí)例

    這篇文章主要介紹了Android手機(jī)鬧鐘用法,以實(shí)例形式較為詳細(xì)的分析了Android實(shí)現(xiàn)鬧鐘功能的頁(yè)面布局及具體功能相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-09-09
  • Android三方依賴沖突Gradle中exclude的使用

    Android三方依賴沖突Gradle中exclude的使用

    這篇文章主要介紹了Android三方依賴沖突Gradle中exclude的使用,文章圍繞主題展開(kāi)詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的小伙伴可以參考一下
    2022-09-09
  • android讀取raw文件示例

    android讀取raw文件示例

    這篇文章主要介紹了android讀取raw文件示例,需要的朋友可以參考下
    2014-02-02
  • Android實(shí)現(xiàn)讀寫(xiě)JSON數(shù)據(jù)的方法

    Android實(shí)現(xiàn)讀寫(xiě)JSON數(shù)據(jù)的方法

    這篇文章主要介紹了Android實(shí)現(xiàn)讀寫(xiě)JSON數(shù)據(jù)的方法,以完整實(shí)例形式分析了Android解析及生成json數(shù)據(jù)的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-10-10
  • Android ListView彈性效果的實(shí)現(xiàn)方法

    Android ListView彈性效果的實(shí)現(xiàn)方法

    這篇文章主要為大家詳細(xì)介紹了Android ListView彈性效果的實(shí)現(xiàn)方法,感興趣的小伙伴們可以參考一下
    2016-05-05
  • Android實(shí)現(xiàn)TextView中文字鏈接的4種方式介紹及代碼

    Android實(shí)現(xiàn)TextView中文字鏈接的4種方式介紹及代碼

    Android實(shí)現(xiàn)TextView中文字鏈接的方式有很多種;總結(jié)起來(lái)大概有4種:用Spannable或?qū)崿F(xiàn)它的類,如SpannableString來(lái)格式,部分字符串等等,感興趣的你可以參考下
    2013-02-02

最新評(píng)論