Android開發(fā)之Activity全透明漸變切換方法
Activity全透明漸變切換
類似于Dialog的顯示動畫效果一樣
1. 先設(shè)置Acitivity為去透明,在取消掉Activity默認(rèn)的切換動畫
<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>//這個之時全透明 <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è)置漸變動畫:
<?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全透明漸變切換方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
Android貝塞爾曲線初步學(xué)習(xí)第二課 仿QQ未讀消息氣泡拖拽黏連效果
這篇文章主要為大家詳細(xì)介紹了Android貝塞爾曲線初步學(xué)習(xí)的第二課,仿QQ未讀消息氣泡拖拽黏連效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-03-03
Android 出現(xiàn):java.lang.NoClassDefFoundError...錯誤解決辦法
這篇文章主要介紹了Android 出現(xiàn):Android出現(xiàn):java.lang.NoClassDefFoundError: android/os/PersistableBundle錯誤解決辦法的相關(guān)資料,需要的朋友可以參考下2017-03-03
Android Studio 2020新版本卡在Gradle downloading/sync failed/下載緩慢/
Android Studio 2020新版本 卡在Gradle downloading / sync failed / 下載緩慢 / 下載超時 親測有效解決辦法,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友參考下吧2020-12-12
Android 5.0 實現(xiàn)水波擴(kuò)散效果
這篇文章主要為大家詳細(xì)介紹了Android 5.0 實現(xiàn)水波擴(kuò)散效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下2019-01-01
Android socket如何實現(xiàn)文件列表動態(tài)訪問
本文介紹Android socket實現(xiàn)文件列表動態(tài)訪問,訪問文件夾之后通過listview展示,并在點(diǎn)擊文件夾后進(jìn)入文件夾,獲得其內(nèi)容,有此需求的朋友可以參考下2021-06-06
Android大作業(yè)功能設(shè)計之自動登錄和記住密碼
SharedPreferences是Android平臺上一個輕量級的存儲類,主要是保存一些常用的配置參數(shù),它是采用xml文件存放數(shù)據(jù)的,文件存放在"/data/data<package?name>/shared_prefs"目錄下,由于SharedPreferences是一個接口,而且在這個接口里沒有提供寫入數(shù)據(jù)和讀取數(shù)據(jù)的能力2023-01-01
Android實現(xiàn)bitmap指定區(qū)域滑動截取功能
這篇文章主要為大家詳細(xì)介紹了Android實現(xiàn)bitmap指定區(qū)域滑動截取功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-09-09

