Icon Padding
Closed this issue · 7 comments
Can we change the padding or margin of icon ?
Pretty sure I've made it like on the standard one of Android, but if you are not happy with it, you can change the layout.
You can do it either by any of those options:
- edit the original "mpl__preference.xml" file
- create your own copy of "mpl__preference.xml" and then edit it. Your copy should automatically replace the one of the library.
- do it via code, by extending the preference you wish to customize, and then change it for the view with id android.R.id.icon .
This is true for any kind of customization of the preferences layout.
1,2 not working
What exactly have you tried? Also, have you considered using margins instead?
- cant edit generated .xml file of library
- created my own copy and it didnt auto replace .xml
-
you are not supposed to edit generated xml files. You are supposed to edit the original file.
-
it must have the exact name, and in the layout folder of your project. I've just tested it now. It works fine.
Here's what I did to the sample project:
a. added the file 'mpl__preference.xml" into the layout folder, and put there a huge padding for the icon:<com.lb.material_preferences_library.internal.widget.PreferenceImageView android:id="@+id/icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:maxHeight="48dp" android:maxWidth="48dp" android:padding="20dp" />
b. edited the "settings_example.xml" and added to one of the preferences the icon:
<com.lb.material_preferences_library.custom_preferences.ListPreference
android:defaultValue="dark"
android:key="@string/pref_theme"
android:summary="%s"
android:title="Theme"
app:dialogTitle="dialog title"
app:entries="@array/pref_theme_list_entries"
app:entryValues="@array/pref_theme_list_values"
app:icon="@android:drawable/sym_def_app_icon"/>
I am using gradle to use library, so how do i edit the original file? I don't think i can do that. Probably second option didn't also work for that reason, maybe i should download and copy library files into project.