這篇文章將為大家詳細(xì)講解有關(guān)如何解決android顯示內(nèi)容被底部導(dǎo)航欄遮擋的問(wèn)題,小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。
成都創(chuàng)新互聯(lián):從2013年成立為各行業(yè)開(kāi)拓出企業(yè)自己的“網(wǎng)站建設(shè)”服務(wù),為上千公司企業(yè)提供了專業(yè)的成都做網(wǎng)站、網(wǎng)站設(shè)計(jì)、網(wǎng)頁(yè)設(shè)計(jì)和網(wǎng)站推廣服務(wù), 按需開(kāi)發(fā)網(wǎng)站由設(shè)計(jì)師親自精心設(shè)計(jì),設(shè)計(jì)的效果完全按照客戶的要求,并適當(dāng)?shù)奶岢龊侠淼慕ㄗh,擁有的視覺(jué)效果,策劃師分析客戶的同行競(jìng)爭(zhēng)對(duì)手,根據(jù)客戶的實(shí)際情況給出合理的網(wǎng)站構(gòu)架,制作客戶同行業(yè)具有領(lǐng)先地位的。
描述:
由于產(chǎn)品需求,要求含有EditText的界面全屏顯示,最好的解決方式是使用AndroidBug5497Workaround.assistActivity(this)
的方式來(lái)解決,但是華為和魅族手機(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)致布局顯示不完全的問(wèn)題 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ū)域 的問(wèn)題 if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){ return (r.bottom - r.top)+statusBarHeight; } return (r.bottom - r.top); } }
關(guān)于“如何解決android顯示內(nèi)容被底部導(dǎo)航欄遮擋的問(wèn)題”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,使各位可以學(xué)到更多知識(shí),如果覺(jué)得文章不錯(cuò),請(qǐng)把它分享出去讓更多的人看到。
新聞名稱:如何解決android顯示內(nèi)容被底部導(dǎo)航欄遮擋的問(wèn)題
URL標(biāo)題:http://muchs.cn/article0/jcpsoo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)建站、App設(shè)計(jì)、虛擬主機(jī)、網(wǎng)站策劃、軟件開(kāi)發(fā)、營(yíng)銷型網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)