Android開發(fā)之Activity全透明漸變切換方法
Activity全透明漸變切換
類似于Dialog的顯示動(dòng)畫效果一樣
1. 先設(shè)置Acitivity為去透明,在取消掉Activity默認(rèn)的切換動(dòng)畫
<style name="AppTheme2" parent="Theme.AppCompat.Light"> <!-- Customize your theme here. --> <item name="windowNoTitle">true</item> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/tabbackground</item> <item name="colorAccent">@color/colorAccent</item> <item name="android:windowBackground">@color/transparent</item>//這個(gè)之時(shí)全透明 <item name="android:windowIsTranslucent">true</item> <item name="android:windowAnimationStyle">@style/activityanimation</item> </style> <style name="activityanimation" > <item name="android:activityOpenEnterAnimation">@null</item> <item name="android:activityOpenExitAnimation">@null</item> <item name="android:activityCloseEnterAnimation">@null</item> <item name="android:activityCloseExitAnimation">@null</item> </style>
2. 設(shè)置漸變動(dòng)畫:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/ll" android:orientation="vertical" android:layout_width="match_parent" android:background="#000" android:layout_height="match_parent"> <MyImageView android:layout_width="match_parent" android:layout_height="300dp" android:layout_centerInParent="true" android:clickable="true" android:background="@mipmap/meinv"/> </RelativeLayout>
public class Activitytwo extends AppCompatActivity{ private int tran=0x00000000; private int end=0x88000000; private RelativeLayout ll; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.ativity); ll = (RelativeLayout) findViewById(R.id.ll); returnposition(); ll.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); } public void returnposition() { ValueAnimator colorAnim = ObjectAnimator.ofInt(ll, "backgroundColor", tran, end); colorAnim.setDuration(300); colorAnim.setEvaluator(new ArgbEvaluator()); colorAnim.start(); } @Override public void finish() { ValueAnimator colorAnim = ObjectAnimator.ofInt(ll, "backgroundColor", end, tran); colorAnim.setDuration(300); colorAnim.setEvaluator(new ArgbEvaluator()); colorAnim.start(); super.finish(); } }
以上這篇Android開發(fā)之Activity全透明漸變切換方法就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
Android拖動(dòng)條的實(shí)現(xiàn)代碼
這篇文章主要為大家詳細(xì)介紹了Android拖動(dòng)條的實(shí)現(xiàn)代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-09-09Android Glide圖片加載(加載監(jiān)聽、加載動(dòng)畫)
這篇文章主要為大家詳細(xì)介紹了Android Glide圖片加載的具體實(shí)現(xiàn)方法,包括加載監(jiān)聽、加載動(dòng)畫,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-11-11Android項(xiàng)目實(shí)戰(zhàn)之ListView懸浮頭部展現(xiàn)效果實(shí)現(xiàn)
這篇文章主要給大家介紹了Android項(xiàng)目實(shí)戰(zhàn)之ListView懸浮頭部展現(xiàn)效果實(shí)現(xiàn)的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2022-01-01Android實(shí)現(xiàn)城市選擇三級(jí)聯(lián)動(dòng)
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)城市選擇三級(jí)聯(lián)動(dòng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-12-12強(qiáng)制Android應(yīng)用使用某個(gè)Locale的方法
這篇文章主要介紹了強(qiáng)制Android應(yīng)用使用某個(gè)Locale的方法,涉及Android基于Locale進(jìn)行語言設(shè)置的相關(guān)技巧,需要的朋友可以參考下2015-10-10Android listview的滑動(dòng)沖突解決方法
這篇文章主要介紹了Android listview的滑動(dòng)沖突解決方法的相關(guān)資料,需要的朋友可以參考下2017-02-02