سؤال

Suppose I have a value for the margin of a view that varies depending on screen sizes. So values-ldpi, mdpi, hdpi, large, xlarge. This works well. Now suppose I want the values to be slightly altered for devices running Android 4.4. If I add the same dimens.xml in values-v19 folder with one slightly altered variable, which dimens.xml would a device running the app consider? The value from the screen sizes folder or the android version folder?

Note that I need to add extra margin on Android 4.4 because I have transparent status bar and hence the layout needs to be under the actionbar as well as the status bar. It is possible programmatically but that would require a lot of work.

Any help is greatly appreciated.

More Detail: I require that the action bar be translucent for all Android versions including 4.4, and the status bar to be translucent for 4.4 as well. Navigation bar should be transparent/translucent too.

هل كانت مفيدة؟

المحلول 2

EDIT: For your end result, your solution should be to set both fitsSystemWindows="true" and clipToPadding="false" on your ScrollView. This will ensure that enough padding is set to put the content within the system bars, but will allow the contents to scroll away underneath.


Check Table 2 here, and you can see in what order of precedence the qualifiers will be matched.

In your case, the screen size takes precedence over the Android version, so if you had:

res/
    values-large/
        dimens.xml
            padding_value = 40dp
    values-v19/
        dimens.xml
            padding_value = 48dp

And tried to use that dimension on a large screen KitKat device, 40dp would be the resolved value.

EDIT: For what you need, just set the attribute android:fitsSystemWindows="true" on the root of your layout -- that will handle insetting the content for the translucent status bar and/or navigation bar automatically. :)

نصائح أخرى

I think you can have folders like values-ldpi, values-mdpi, .... and also values-ldpi-v19, values-mdpi-v19, .... and so on. Here is a link for more information about configuration qualifier names.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top