欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

Android中如何創(chuàng)建類似Instagram的漸變背景效果-創(chuàng)新互聯(lián)

這篇文章主要為大家展示了“Android中如何創(chuàng)建類似Instagram的漸變背景效果”,內(nèi)容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領大家一起研究并學習一下“Android中如何創(chuàng)建類似Instagram的漸變背景效果”這篇文章吧。

創(chuàng)新互聯(lián)專注于大連企業(yè)網(wǎng)站建設,自適應網(wǎng)站建設,電子商務商城網(wǎng)站建設。大連網(wǎng)站建設公司,為大連等地區(qū)提供建站服務。全流程按需設計網(wǎng)站,專業(yè)設計,全程項目跟蹤,創(chuàng)新互聯(lián)專業(yè)和態(tài)度為您提供的服務

效果圖:

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)建一個用到上面創(chuàng)建的漸變色的動畫序列,命名為animation_list.xml,放進去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)建好的動畫序列應用到你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去實現(xiàn)過渡效果

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

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

將狀態(tài)欄設置透明(去除狀態(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)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學習更多知識,歡迎關注創(chuàng)新互聯(lián)行業(yè)資訊頻道!

新聞名稱:Android中如何創(chuàng)建類似Instagram的漸變背景效果-創(chuàng)新互聯(lián)
當前鏈接:http://chinadenli.net/article48/jihep.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供企業(yè)建站、外貿(mào)建站建站公司、網(wǎng)站收錄、靜態(tài)網(wǎng)站網(wǎng)站設計公司

廣告

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

h5響應式網(wǎng)站建設
亚洲欧美日本视频一区二区| 日本精品中文字幕在线视频| 日本精品视频一二三区| 国产伦精品一一区二区三区高清版| 日韩欧美国产亚洲一区| 亚洲中文字幕乱码亚洲| 亚洲国产成人久久99精品| 亚洲免费观看一区二区三区| 欧美欧美日韩综合一区| 色综合久久超碰色婷婷| 五月天丁香亚洲综合网| 国产内射一级二级三级| 久草热视频这里只有精品| 午夜精品福利视频观看| 国产午夜福利一区二区| 大胆裸体写真一区二区| 日韩欧美国产亚洲一区| 青青操精品视频在线观看| 国产av精品一区二区| 东京热加勒比一区二区三区| 黄男女激情一区二区三区| 亚洲av一区二区三区精品| 久热香蕉精品视频在线播放| 成年女人下边潮喷毛片免费| 国产午夜在线精品视频| 免费在线观看欧美喷水黄片| 丰满少妇高潮一区二区| 亚洲精品国男人在线视频| 精品人妻一区二区三区免费看| 91日韩在线视频观看| 五月天综合网五月天综合网| 日韩丝袜诱惑一区二区| 久久亚洲午夜精品毛片| 日韩在线视频精品视频| 四十女人口红哪个色好看| 老熟妇2久久国内精品| 欧美丝袜诱惑一区二区| 精品人妻一区二区三区四区久久| 亚洲综合一区二区三区在线| 成人精品国产亚洲av久久| 黑丝袜美女老师的小逼逼|