我在Nexus 5(Android5)上运行我的应用程序,但我遇到了一个问题,就是底部的软NavigationBar与ListView的最后一项重叠。我尝试过将fitsSystemWindows添加到我的风格和ListView中,但这没有起作用。
布局的XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:background="@color/sf4l"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView android:id="@id/android:list"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@color/sf4l" />
</LinearLayout>发布于 2015-03-26 02:07:22
将其添加到themes.xml的值-v21 dir中:
<item name="android:windowDrawsSystemBarBackgrounds">false</item>示例(我在为actionbar使用AppCompat ):
<style name="Theme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="homeAsUpIndicator">@drawable/new_indicator</item>
<item name="android:homeAsUpIndicator">@drawable/new_indicator</item>
<item name="actionModeBackground">@android:color/black</item>
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
</style>发布于 2017-03-24 16:42:26
这是因为您的listView的高度是相等的全屏高度,但动作栏推动布局很少像素低,这是什么导致布局重叠的导航按钮。
如果在操作栏下有全屏片段容器,也会发生这种情况。
修正方法是将屏幕和操作栏的高度设置为中间,然后将父视图的高度设置为它的差异。示例:
@Override
public void onWindowFocusChanged (boolean hasFocus) {
LinearLayout lMain = (LinearLayout) findViewById(R.id.lMain);
lMain.getLayoutParams().height = lMain.getHeight() - getNavigationBarHeight();
}发布于 2017-11-30 06:45:52
我在这篇文章中尝试了这个被接受的答案,就像很多时候一样,它对我没有用。
然而,下面的工人为我。
<item name="android:windowTranslucentNavigation">false</item>我放进了样式-21.xml
所做的是使软导航条有一个坚实的背景,并以某种方式,现在组件被正确地呈现。
https://stackoverflow.com/questions/27723322
复制相似问题