После выполнения этих шагов я столкнулся с проблемой: https://codelabs.developers.google.com/codelabs/android-training-adding-settings-to-app/index.html?index=..%2F..android-training#2
По какой-то причине, когда я создаю экран предпочтений, например, я не могу увидеть или перетащить виды из палитры, например, так:
Но когда я делаю то же самое, записывая код в xml, он появляется.
![coding in XML file](https://i.stack.imgur.com/lMaBY.png)
Почему это так и как это исправить? Другой вопрос, который у меня возник, заключается в том, как настроить ширину и высоту видов на экране предпочтений?
xml файл:
<?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
<SwitchPreference
android:defaultValue="true"
android:key="example_switch"
android:summary="Turn this option on or off"
android:title="Settings Option"
/>
</androidx.preference.PreferenceScreen>
зависимости gradle:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.navigation:navigation-fragment:2.2.1'
implementation 'androidx.navigation:navigation-ui:2.2.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'androidx.preference:preference:1.1.0'
}
каталогов:
![dirs](https://i.stack.imgur.com/O03Vv.png)
Я использую шаблон активности Basi c