微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android – fitsSystemWindows和kitkat上的额外填充

我在一个带有动作栏的活动中有一个ListView,如下所示:
<LinearLayout
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:android="http://schemas.android.com/apk/res/android"
    tools:context=".LauncherActivity"

    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
        <ListView
            android:id="@+id/lvcalendar"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:clipToPadding="false"
            android:fitsSystemWindows="true"


            android:dividerHeight="10dp"
            android:paddingTop="10dp"
            android:paddingBottom="10dp"
            android:divider="#00ffffff"

            android:scrollbarThumbVertical="@drawable/scrollbarstyle"
            android:layout_gravity="top"
            android:listSelector="@android:color/transparent"
            />
</LinearLayout>

活动主题包括

<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>

在Kitkat设备下,行为是我想要的:项目底部和顶部都有10dp填充.在kitkat设备上,paddingTop和paddingBottom似乎没有效果,因为ListView的项目在顶部和底部没有10dp填充.

我认为问题出在android:fitsSystemWindows中,因为这个属性似乎设置了必要的填充到视图,因为半透明的装饰,并使android:padding *属性被忽略.

我的问题:无论如何,我可以将android:fitsSystemWindows设置为true并仍然在视图上添加额外的填充?

解决方法

您应该将此属性添加到父视图:
<LinearLayout
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
tools:context=".LauncherActivity"
android:fitsSystemWindows="true"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐