欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

Android中怎么創(chuàng)建類似Instagram的漸變背景效果

本篇內(nèi)容介紹了“Android中怎么創(chuàng)建類似Instagram的漸變背景效果”的有關(guān)知識,在實(shí)際案例的操作過程中,不少人都會(huì)遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!

創(chuàng)新互聯(lián) - 雙線服務(wù)器托管,四川服務(wù)器租用,成都服務(wù)器租用,四川網(wǎng)通托管,綿陽服務(wù)器托管,德陽服務(wù)器托管,遂寧服務(wù)器托管,綿陽服務(wù)器托管,四川云主機(jī),成都云主機(jī),西南云主機(jī),雙線服務(wù)器托管,西南服務(wù)器托管,四川/成都大帶寬,成都機(jī)柜租用,四川老牌IDC服務(wù)商

效果圖:

Android中怎么創(chuàng)建類似Instagram的漸變背景效果

1. 在drawable文件夾創(chuàng)建一些漸變顏色的資源

color1.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
  <gradient
    android:startColor="#614385"
    android:endColor="#516395"
    android:angle="0"/>
</shape>

color2.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
  <gradient
    android:startColor="#5f2c82"
    android:endColor="#49a09d"
    android:angle="45"/>
</shape>

color3.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
  <gradient
    android:startColor="#4776E6"
    android:endColor="#8E54E9"
    android:angle="90"/>
</shape>

color4.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
  <gradient
    android:startColor="#7141e2"
    android:endColor="#d46cb3"
    android:angle="135"/>
</shape>

2. 創(chuàng)建一個(gè)用到上面創(chuàng)建的漸變色的動(dòng)畫序列,命名為animation_list.xml,放進(jìn)去drawable文件夾

<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android">
  <item
    android:drawable="@drawable/color1"
    android:duration="10000" />
  <item
    android:drawable="@drawable/color2"
    android:duration="10000" />
  <item
    android:drawable="@drawable/color3"
    android:duration="10000" />
  <item
    android:drawable="@drawable/color4"
    android:duration="10000" />
</animation-list>

3. 將上面已經(jīng)創(chuàng)建好的動(dòng)畫序列應(yīng)用到你layout的背景頂層的view中

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical"
  android:background="@drawable/animation_list"
  android:id="@+id/container">
  <!-- Child Views -->
</LinearLayout>

4.在你的activity中用AnimationDrawable去實(shí)現(xiàn)過渡效果

LinearLayout container = (LinearLayout) findViewById(R.id.container);
AnimationDrawable anim = (AnimationDrawable) container.getBackground();
anim.setEnterFadeDuration(6000);
anim.setExitFadeDuration(2000);

// 開始播放動(dòng)畫:在onResume方法中開始播放漸變動(dòng)畫
@Override
protected void onResume() {
  super.onResume();
  if (anim != null && !anim.isRunning())
    anim.start();
}
   
// 停止播放動(dòng)畫:在onPause方法中停止播放漸變動(dòng)畫
@Override
protected void onPause() {
  super.onPause();
  if (anim != null && anim.isRunning())
    anim.stop();
}

將狀態(tài)欄設(shè)置透明(去除狀態(tài)欄)

values/styles.xml

<resources> 
  <style name="Theme.AppTheme.TranslucentStatusBar" parent="Theme.AppCompat.Light.NoActionBar" /> 
</resources>

values-v19/styles.xml

<resources> 
  <style name="Theme.AppTheme.TranslucentStatusBar" parent="Theme.AppCompat.Light.NoActionBar"> 
    <item name="android:windowTranslucentStatus">true</item> 
  </style> 
</resources>

values-v21/styles.xml

<resources> 
  <style name="Theme.AppTheme.TranslucentStatusBar" parent="Theme.AppCompat.Light.NoActionBar"> 
    <item name="android:statusBarColor">@android:color/transparent</item> 
  </style> 
</resources>

values-v23/styles.xml

<resources> 
  <style name="Theme.AppTheme.TranslucentStatusBar" parent="Theme.AppCompat.Light.NoActionBar"> 
    <item name="android:statusBarColor">@android:color/transparent</item> 
    <item name="android:windowLightStatusBar">true</item> 
  </style> 
</resources>
public class MainActivity extends AppCompatActivity { 
  @Override 
  protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState);  
    // 加入下面的代碼
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 
      findViewById(android.R.id.content).setSystemUiVisibility( 
          View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); 
    } 
 
    setContentView(R.layout.activity_splash); 
  } 
} 
<activity 
  android:name=".MainActivity"  android:theme="@style/Theme.AppTheme.TranslucentStatusBar" />

“Android中怎么創(chuàng)建類似Instagram的漸變背景效果”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!

網(wǎng)頁題目:Android中怎么創(chuàng)建類似Instagram的漸變背景效果
文章地址:http://aaarwkj.com/article42/gjdoec.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站策劃定制開發(fā)、網(wǎng)站導(dǎo)航用戶體驗(yàn)、網(wǎng)頁設(shè)計(jì)公司面包屑導(dǎo)航

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)
国产亚洲精品a久久7777| 日韩欧美精品久久黄| 黄片大全视频在线免费观看| 国产一区二区三区不卡av| 九九视频免费观看5| 成人黄色av在线看| 天天日天天天干夜夜操| 在线观看91精品国产秒播| 加勒比在线观看欧美一区| 91亚洲熟妇国产熟妇肥婆| 亚洲精品国产精品乱码不| 夫妻性生活短是什么原因| 精彩国产av一区二区三区| 不卡视频一区中文字幕| av福利一区二区三区| 91久久国产综合精品| 亚洲国产精品福利在线| 中文字幕有码在线朋友| 久久精品国产亚洲av麻| 亚洲精品有码中文字幕| 91一区二区亚洲嫩草| 国产日韩一区二区三区电影| 色哟哟网站在线精品视频| 日本欧美自拍偷拍高清| 一本久道久久综合久久鬼色| 亚洲精品黄色片中文字幕| 美女在线免费观看av| 侵犯人妻中文字幕一区二区| 午夜福利视频一区久久久| 美女爽到高潮久久久| 国产一区二区三区精品女同| 亚洲午夜一区二区不卡| 欧美成人精品午夜一区二区| 国产三级三级在线观看| 传媒视频免费在线观看| 97热久久精品中文字幕一区| 国产精品国产三级国产专用| 亚洲三级黄片在线观看| 国产日韩在线不卡网站| 九九热精品视频美谷朱里| 久久精品国产亚洲av清纯|