Thursday, 16 May 2019

Some style attributes are missing after migrating from support library to AndroidX

By refering to https://android.googlesource.com/platform/frameworks/base/+/master/core/res/res/layout/simple_spinner_item.xml and https://pep-security.lu/gitlab/android/pep/blame/2f5b1397ba73f78f49f2094b9fb370d2fee62635/k9mail/src/main/res/layout/simple_spinner_item.xml

Currently, we have the following dropdown view item. It is using style ?android:attr/spinnerDropDownItemStyle

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingLeft="8dp"
    android:paddingRight="8dp">

    <CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/checked_text_view_0"
        style="?android:attr/spinnerDropDownItemStyle"
        android:singleLine="true"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:minHeight="48dp" />

</LinearLayout>

We use the above XML in a custom ArrayAdapter. The custom ArrayAdapter will then attached to Spinner

repeatInfoSpinner.setAdapter(repeatInfoArrayAdapter);

When we are using support library (Before migrating to AndroidX), it looks like this. It comes with nice touch ripple effect.

enter image description here


After migrating to AndroidX, it looks like legacy holo design.

enter image description here


It seems that, the style attribute which is previously found in support library (https://chromium.googlesource.com/android_tools/+/bf45c76e0eb23b7b7a9d5f26b28c16983daa173b/sdk/extras/android/support/v7/appcompat/res/values/themes.xml#33) , no longer found in AndroidX.


May I know, how can we resolve such, to make our app looks like material design app?

Note, I had tried ?attr/spinnerDropDownItemStyle. It makes no difference.



from Some style attributes are missing after migrating from support library to AndroidX

No comments:

Post a Comment