PreferenceFragmentCompat tem preenchimento no PreferenceCategory do qual não consigo me livrar
Então, eu tentei criar uma atividade de configurações usando androidx.preference.PreferenceFragmentCompat e está tudo funcionando bem.
No entanto, por algum motivo, há algum preenchimento presente nas categorias de preferências e nas próprias preferências. Consegui me livrar do preenchimento das preferências usando app: iconSpaceReserved = "false", mas isso não parece funcionar nas categorias.
Eu tentei todos os vários temas, PreferenceThemeOverlay.v14.Material etc, mas eles não parecem fazer a diferença
Aqui está o meu código para tudo!
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);
}
}
preferências_teste.xml
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="test" >
<Preference android:title="testPref" />
</PreferenceCategory>
</PreferenceScreen>
Minhas dependências são ...
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'
Obrigado pela ajuda.