I'm having some problems with my preferenceactivity. The code show the screen perfect on preview, but when I test on emulator Its show a extra padding on SwitchPreference, and the switch doesn't work.
Besides that, when testing on pre-lollipop emulator, theres no margin at all.
My code:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<SwitchPreference
android:title="Tema"
android:key="night_mode"
android:summary="Ativar tema escuro"/>
<CheckBoxPreference
android:title="App Update"
android:defaultValue="true"
android:summary="This option if selected will allow the application to check for latest versions."
android:key="app_update"/>
<Preference
android:title="Clean cache"
android:summary="Resetar preferencias do app"
android:key="clean_cache"/>
<PreferenceScreen
android:title="Sobre">
<intent android:targetClass="llamaze.com.br.whattodraw.Activitys.AboutActivity"
android:targetPackage="llamaze.com.br.whattodraw"/>/
</PreferenceScreen>/
</PreferenceScreen>
public static class PrefsFragment extends PreferenceFragmentCompat {
Context context;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
Preference customPref = findPreference("clean_cache");
customPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
showDialogCache();
Log.d("PREFRE", "onPreferenceClick: foi clicado");
return false;
}
});
}
Well, the problem was resolved by google with the update of preference-v7 to 24.1.1