Search code examples
androidsettingspreference

custom preference layout and theme consistent with the default one?


I am new to android development. I am working on settings preference (seekbar preference to be specific), I know how to customize a preference's layout, but the theme, layout or style are not consistent with the default one, so my question is, how can I make it (text size, padding, margin etc.) the same as the default one? for instance, the sound setting in system setting the sound setting seekbar preference

enter image description here


Solution

  • how can I make it (text size, padding, margin etc.) the same as the default one?

    Base yours on one of the layouts used for an existing preference type. Those layouts can be found in $ANDROID_SDK/platforms/.../data/res/layout/, where$ANDROID_SDKis wherever you have installed the Android SDK and...is some platform version (e.g.,android-26for Android 8.0). The layout resources prefixed withpreference_pertain to preferences, andpreference_widget_seekbar_material.xml` is the Material Design one.

    If you were using appcompat-v7, you would perform a similar operation, poking through that library's code, which is part of this AOSP repo.