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

首頁 > 學院 > 開發(fā)設(shè)計 > 正文

andriod沉浸實現(xiàn)(全面)

2019-11-09 14:31:41
字體:
供稿:網(wǎng)友
app實現(xiàn)沉浸效果能使界面效果更加和諧,改善用戶體驗。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()方法中進行設(shè)置[java] view plaincopy    //設(shè)置標題欄的顏色          getActionBar().setBackgroundDrawable(new ColorDrawable(Color.rgb(51, 181, 250)));      // 創(chuàng)建狀態(tài)欄的管理實例           <span style="white-space:PRe"> </span>SystemBarTintManager tintManager = new SystemBarTintManager(this);        // 激活狀態(tài)欄設(shè)置            tintManager.setStatusBarTintEnabled(true);        // 激活導(dǎo)航欄設(shè)置            tintManager.setNavigationBarTintEnabled(true);        // 設(shè)置一個顏色給系統(tǒng)欄           tintManager.setTintColor(Color.rgb(51, 181, 250));  方法二:下載支持jar包:http://download.csdn.net/detail/u012193089/9022715直接在MainActivity.java的onCreate()方法中添加[java] view plaincopy// 設(shè)置狀態(tài)欄顏色          getActionBar().setBackgroundDrawable(                  new ColorDrawable(Color.rgb(51, 181, 250)));  //判斷版本          if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {              setTranslucentStatus(true);          }  //創(chuàng)建實例          SystemBarTintManager tintManager = new SystemBarTintManager(this);  [java] view plaincopy//激活,設(shè)置顏色          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>
然后運行程序可以看到,狀態(tài)欄與app頂部顏色是一致的,但是如果布局文件的頂部寫有其它內(nèi)容的話會發(fā)現(xiàn)布局文件上的內(nèi)容會與狀態(tài)欄上的內(nèi)容重合~~這肯定是不允許的。有沒有方法解決呢?在使用了沉浸式狀態(tài)欄的布局文件上寫上以下兩句話: 然后在要使用沉浸式狀態(tài)欄的布局文件上寫上兩句代碼:
android:clipToPadding="true"android:fitsSystemWindows="true"
方法一和方法二在沒有使用actionbar的情況下要把 getActionBar().setBackgroundDrawable(new ColorDrawable(Color.rgb(51181250)));  去掉,單獨設(shè)置狀態(tài)欄的顏色,另外要在根布局里加上
android:clipToPadding="true"android:fitsSystemWindows="true"
否則會出現(xiàn)狀態(tài)欄遮蓋內(nèi)容的現(xiàn)象。方法三的導(dǎo)航欄顏色設(shè)置區(qū)別于方法一和方法二是在根布局里設(shè)置背景色
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 视频| 岑溪市| 土默特右旗| 高州市| 浦北县| 三原县| 合肥市| 乌兰县| 南漳县| 游戏| 平南县| 尉犁县| 驻马店市| 灵台县| 丰原市| 琼结县| 色达县| 龙陵县| 安顺市| 改则县| 凤凰县| 通江县| 成武县| 石景山区| 榆中县| 远安县| 得荣县| 越西县| 满洲里市| 布拖县| 岳阳县| 三台县| 雅安市| 庆云县| 濮阳县| 曲麻莱县| 成武县| 德格县| 彰化市| 宁蒗| 辽阳县|