成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

如何解決android顯示內(nèi)容被底部導航欄遮擋的問題-創(chuàng)新互聯(lián)

這篇文章將為大家詳細講解有關如何解決android顯示內(nèi)容被底部導航欄遮擋的問題,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。

創(chuàng)新互聯(lián)公司專業(yè)為企業(yè)提供晉中網(wǎng)站建設、晉中做網(wǎng)站、晉中網(wǎng)站設計、晉中網(wǎng)站制作等企業(yè)網(wǎng)站建設、網(wǎng)頁設計與制作、晉中企業(yè)網(wǎng)站模板建站服務,十余年晉中做網(wǎng)站經(jīng)驗,不只是建網(wǎng)站,更提供有價值的思路和整體網(wǎng)絡服務。

描述:

由于產(chǎn)品需求,要求含有EditText的界面全屏顯示,最好的解決方式是使用AndroidBug5497Workaround.assistActivity(this)

的方式來解決,但是華為和魅族手機系統(tǒng)自帶的有底部導航欄,會造成一些布局被遮擋。

解決方案:在values-21的style.xml中添加android:windowDrawsSystemBarBackgrounds”并將值設置為false,方式如下

在style引用的主題里面加入android:windowDrawsSystemBarBackgrounds”并將值設置為false,會自動提醒點擊alt+Enter會新建values-21的文件夾并生成styles.xml的文件。

也可以自己忽略的,直接新建values-21的文件夾然后新建一個styles.xml的文件,將主題里面的內(nèi)容復制到styles.xml里面然后加上加入android:windowDrawsSystemBarBackgrounds”并將值設置為false即可解決。

例外:附上(網(wǎng)上找到的)

public class AndroidBug5497Workaround {
 
 // For more information, see https://code.google.com/p/android/issues/detail?id=5497
 // To use this class, simply invoke assistActivity() on an Activity that already has its content 
 
view set.
 
 public static void assistActivity (Activity activity) {
 new AndroidBug5497Workaround(activity);
 }
 private Activity activity;
 private View mChildOfContent;
 private int usableHeightPrevious;
 private FrameLayout.LayoutParams frameLayoutParams;
 
 private AndroidBug5497Workaround(Activity activity) {
 this.activity = activity;
 FrameLayout content = (FrameLayout) activity.findViewById(android.R.id.content);
 mChildOfContent = content.getChildAt(0);
 mChildOfContent.getViewTreeObserver().addOnGlobalLayoutListener(new 
 
ViewTreeObserver.OnGlobalLayoutListener() {
  public void onGlobalLayout() {
  possiblyResizeChildOfContent();
  }
 });
 frameLayoutParams = (FrameLayout.LayoutParams) mChildOfContent.getLayoutParams();
 }
 
 private void possiblyResizeChildOfContent() {
 int usableHeightNow = computeUsableHeight();
 LogUtils.e("possiblyResizeChildOfContent","usableHeightNow:"+usableHeightNow);
 LogUtils.e("possiblyResizeChildOfContent","usableHeightPrevious:"+usableHeightPrevious);
 if (usableHeightNow != usableHeightPrevious) {
  int usableHeightSansKeyboard = mChildOfContent.getRootView().getHeight();
 
  //這個判斷是為了解決19之前的版本不支持沉浸式狀態(tài)欄導致布局顯示不完全的問題
  if(Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT){
  Rect frame = new Rect();
  activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
  int statusBarHeight = frame.top;
  usableHeightSansKeyboard -= statusBarHeight;
  }
  int heightDifference = usableHeightSansKeyboard - usableHeightNow;
  if (heightDifference > (usableHeightSansKeyboard/4)) {
  // keyboard probably just became visible
  frameLayoutParams.height = usableHeightSansKeyboard - heightDifference;
  } else {
  // keyboard probably just became hidden
  frameLayoutParams.height = usableHeightSansKeyboard;
  }
  mChildOfContent.requestLayout();
  usableHeightPrevious = usableHeightNow;
 }
 }
 
 private int computeUsableHeight() {
 Rect frame = new Rect();
 activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
 int statusBarHeight = frame.top;
 
 Rect r = new Rect();
 mChildOfContent.getWindowVisibleDisplayFrame(r);
 
 //這個判斷是為了解決19之后的版本在彈出軟鍵盤時,鍵盤和推上去的布局(adjustResize)之間有黑色區(qū)域
 
的問題
 if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
  return (r.bottom - r.top)+statusBarHeight;
 }
 
 return (r.bottom - r.top);
 }
 
}

關于“如何解決android顯示內(nèi)容被底部導航欄遮擋的問題”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。

網(wǎng)站題目:如何解決android顯示內(nèi)容被底部導航欄遮擋的問題-創(chuàng)新互聯(lián)
網(wǎng)站URL:http://jinyejixie.com/article30/dedjpo.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供電子商務、全網(wǎng)營銷推廣App開發(fā)、網(wǎng)站改版、網(wǎng)站營銷網(wǎng)站內(nèi)鏈

廣告

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

商城網(wǎng)站建設
西乡县| 松江区| 崇信县| 永嘉县| 南城县| 赫章县| 图木舒克市| 瓮安县| 屏东县| 高陵县| 金阳县| 桃源县| 嘉定区| 城步| 澄江县| 封丘县| 乌兰察布市| 宁化县| 静海县| 惠水县| 公安县| 香河县| 华蓥市| 阳城县| 沂水县| 贵南县| 盱眙县| 冕宁县| 德钦县| SHOW| 吉林市| 铜鼓县| 巨野县| 余庆县| 修文县| 汝城县| 始兴县| 怀远县| 额尔古纳市| 理塘县| 沙洋县|