FitsSystemWindows and add-on kitkat

I have a ListView in action with an action bar like this:

<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> 

Activity Topic:

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

On Kitkat devices, behavior is what I want: elements have 10dp padding at the bottom and top. On kitkat devices, paddingTop and paddingBottom do not seem to have an effect, since the ListView element does not have 10dp padding at the top and bottom.

I think the problem is somewhere in android:fitsSystemWindows , since this attribute seems to set the necessary addition to the view due to transparent decoding and ignore the android:padding* attributes.

My question is : anyway, so I can set android:fitsSystemWindows to true and add an extra padding to the view?

+7
android android-4.4-kitkat
source share
4 answers

You must add this attribute to the parent view:

 <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" > 
+14
source share

You can create your own class that extends ListView and overrides fitSystemWindows() in this class to add inserts to an existing add-on (the default implementation replaces any padding with inserts). Then you do not need to specify the android:fitsSystemWindows in the XML layout, because your new implementation will always be called.

+1
source share

The answer is no. If you set android: fitsSystemWindows to true, it overwrites the complement of this view.

You can achieve the desired behavior by having two nested views, where the parent view is android: fitsSystemWindows as true, and the other contains an addition.

0
source share

Using:

 fitsSystemWindows=true 

To the layout, the padding will reset on the inserts. You can use FitsSystemWindowsFrameLayout to solve this default behavior.

-one
source share

All Articles