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

首頁 > 系統(tǒng) > Android > 正文

解決android 顯示內(nèi)容被底部導(dǎo)航欄遮擋的問題

2019-10-21 21:45:11
字體:
供稿:網(wǎng)友

描述:

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

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

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

在style引用的主題里面加入android:windowDrawsSystemBarBackgrounds”并將值設(shè)置為false,會(huì)自動(dòng)提醒點(diǎn)擊alt+Enter會(huì)新建values-21的文件夾并生成styles.xml的文件。

也可以自己忽略的,直接新建values-21的文件夾然后新建一個(gè)styles.xml的文件,將主題里面的內(nèi)容復(fù)制到styles.xml里面然后加上加入android:windowDrawsSystemBarBackgrounds”并將值設(shè)置為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();   //這個(gè)判斷是為了解決19之前的版本不支持沉浸式狀態(tài)欄導(dǎo)致布局顯示不完全的問題  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);  //這個(gè)判斷是為了解決19之后的版本在彈出軟鍵盤時(shí),鍵盤和推上去的布局(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)容被底部導(dǎo)航欄遮擋的問題就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持VEVB武林網(wǎng)。


注:相關(guān)教程知識(shí)閱讀請(qǐng)移步到Android開發(fā)頻道。
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 深圳市| 三明市| 勐海县| 民和| 视频| 平罗县| 长海县| 伊吾县| 攀枝花市| 江川县| 普安县| 沙洋县| 铜鼓县| 金堂县| 抚州市| 左云县| 宣威市| 德化县| 页游| 来安县| 广安市| 遵化市| 衡南县| 红原县| 仙桃市| 北川| 浦江县| 安达市| 正镶白旗| 竹山县| 新余市| 建平县| 轮台县| 泸溪县| 个旧市| 五寨县| 方正县| 东阿县| 晋江市| 城市| 毕节市|