PreferenceFragmentCompat tiene relleno en PreferenceCategory que no puedo eliminar
Así que he estado tratando de crear una actividad de configuración usando androidx.preference.PreferenceFragmentCompat y todo funciona bien.
Sin embargo, por alguna razón hay algo de relleno tanto en las categorías de preferencias como en las preferencias mismas. Logré deshacerme del relleno en las preferencias mediante el uso de la aplicación: iconSpaceReserved = "false", pero esto no parece funcionar en las categorías.
He probado todos los diversos temas, PreferenceThemeOverlay.v14.Material, etc., pero no parecen hacer la diferencia
Aquí está mi código para todo!
SettingsActivity.java
import android.os.Bundle;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
public class SettingsActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
Toolbar toolbar = findViewById(R.id.settings_toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowTitleEnabled(false);
}
}
}
activity_settings.xml
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".SettingsActivity">
<androidx.appcompat.widget.Toolbar
android:id="@+id/settings_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
style="@style/ToolbarTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title_settings"
android:textColor="@color/font_dark_primary" />
</androidx.appcompat.widget.Toolbar>
<fragment
android:name="com.henrytwist8gmail.fullcart.SettingsTestFragment"
android:tag="settings_fragment"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/settings_toolbar" />
</androidx.constraintlayout.widget.ConstraintLayout>
SettingsTestFragment.java
import android.os.Bundle;
import androidx.preference.PreferenceFragmentCompat;
public class SettingsTestFragment extends PreferenceFragmentCompat {
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.preferences_test, rootKey);
}
}
ferences_test.xml
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="test" >
<Preference android:title="testPref" />
</PreferenceCategory>
</PreferenceScreen>
Mis dependencias son ...
implementation 'com.google.android.material:material:1.0.0-beta01'
implementation 'androidx.preference:preference:1.0.0-beta01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
Gracias por tu ayuda