国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

andriod沉浸實現(全面)

2019-11-09 13:49:22
字體:
來源:轉載
供稿:網友
app實現沉浸效果能使界面效果更加和諧,改善用戶體驗。Andriod在API19之后還是支持沉浸效果,下main介紹三種方法:方法一:下載支持jar包:http://download.csdn.net/detail/u012193089/90227151、在stylex.xml中你所引用的主題style<>中加入[java] view plaincopy<!-- Status Bar -->  <item name="android:windowTranslucentStatus">true</item>  <!-- Navigation Bar -->  <item name="android:windowTranslucentNavigation">true</item>  2、在MainActivity.java的onCreate()方法中進行設置[java] view plaincopy    //設置標題欄的顏色          getActionBar().setBackgroundDrawable(new ColorDrawable(Color.rgb(51, 181, 250)));      // 創建狀態欄的管理實例           <span style="white-space:PRe"> </span>SystemBarTintManager tintManager = new SystemBarTintManager(this);        // 激活狀態欄設置            tintManager.setStatusBarTintEnabled(true);        // 激活導航欄設置            tintManager.setNavigationBarTintEnabled(true);        // 設置一個顏色給系統欄           tintManager.setTintColor(Color.rgb(51, 181, 250));  方法二:下載支持jar包:http://download.csdn.net/detail/u012193089/9022715直接在MainActivity.java的onCreate()方法中添加[java] view plaincopy// 設置狀態欄顏色          getActionBar().setBackgroundDrawable(                  new ColorDrawable(Color.rgb(51, 181, 250)));  //判斷版本          if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {              setTranslucentStatus(true);          }  //創建實例          SystemBarTintManager tintManager = new SystemBarTintManager(this);  [java] view plaincopy//激活,設置顏色          tintManager.setStatusBarTintEnabled(true);          tintManager.setTintColor(Color.rgb(51, 181, 250));      }        @TargetApi(19)       private void setTranslucentStatus(boolean on) {          Window win = getWindow();          WindowManager.LayoutParams winParams = win.getAttributes();          final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;          if (on) {              winParams.flags |= bits;          } else {              winParams.flags &= ~bits;          }          win.setAttributes(winParams);      }  以上兩種方法摘錄于itbobby的專欄(http://blog.csdn.net/u012193089/article/details/47778433)方法三:在style上寫以下代碼:指定style為noactionbar而且半透明
<resources xmlns:android="http://schemas.android.com/apk/res/android"><style type="text/CSS" parent="android:Theme.Holo.Light.NoActionBar.TranslucentDecor" name="AppBaseTheme"></style></resources>
然后運行程序可以看到,狀態欄與app頂部顏色是一致的,但是如果布局文件的頂部寫有其它內容的話會發現布局文件上的內容會與狀態欄上的內容重合~~這肯定是不允許的。有沒有方法解決呢?在使用了沉浸式狀態欄的布局文件上寫上以下兩句話: 然后在要使用沉浸式狀態欄的布局文件上寫上兩句代碼:
android:clipToPadding="true"android:fitsSystemWindows="true"
方法一和方法二在沒有使用actionbar的情況下要把 getActionBar().setBackgroundDrawable(new ColorDrawable(Color.rgb(51181250)));  去掉,單獨設置狀態欄的顏色,另外要在根布局里加上
android:clipToPadding="true"android:fitsSystemWindows="true"
否則會出現狀態欄遮蓋內容的現象。方法三的導航欄顏色設置區別于方法一和方法二是在根布局里設置背景色
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 苏州市| 承德市| 长治市| 呼图壁县| 本溪| 晋宁县| 陈巴尔虎旗| 怀柔区| 文昌市| 阿鲁科尔沁旗| 黔西县| 正定县| 湟中县| 许昌县| 诏安县| 峡江县| 临猗县| 阿勒泰市| 陇南市| 久治县| 廉江市| 鄂尔多斯市| 平山县| 垣曲县| 克拉玛依市| 济南市| 莆田市| 南平市| 拜泉县| 鹿泉市| 大埔县| 昌乐县| 民丰县| 松阳县| 宜兰县| 武川县| 罗田县| 久治县| 同心县| 仪陇县| 临西县|