Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does `PreferenceScreen` need height and width?

Tags:

android

I got the following code from the android documentation

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
    <CheckBoxPreference
        android:key="pref_sync"
        android:title="@string/pref_sync"
        android:summary="@string/pref_sync_summ"
        android:defaultValue="true" />
    <ListPreference
        android:dependency="pref_sync"
        android:key="pref_syncConnectionType"
        android:title="@string/pref_syncConnectionType"
        android:dialogTitle="@string/pref_syncConnectionType"
        android:entries="@array/pref_syncConnectionTypes_entries"
        android:entryValues="@array/pref_syncConnectionTypes_values"
        android:defaultValue="@string/pref_syncConnectionTypes_default" />
</PreferenceScreen>

Android studio is giving me an error saying I am missing Height and Width on the PreferenceScreen tag. It's easy enough to fix but I can't believe the doc would have invalid code so I am curious if I am doing something wrong and I am missing a setting somewhere.

like image 757
Mika Avatar asked Dec 20 '22 15:12

Mika


1 Answers

Probably a studio bug recognizing PreferenceScreen as layouts if you misplaced it in res/layout/ folder.

Your preference xml should be res/xml/ folder.

like image 106
Yaroslav Mytkalyk Avatar answered Jan 01 '23 18:01

Yaroslav Mytkalyk