Проблема с Android: невозможно добавить более 11 просмотров в ScrollView - PullRequest
0 голосов
/ 02 марта 2011

Это мой первый вопрос по stackOverflow, так что поехали:

У меня есть этот макет:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<LinearLayout
android:id="@+id/widget31"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<TextView
android:id="@+id/set_reader_tv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Reader Settings:"
android:typeface="serif"
android:textStyle="bold"
android:textSize="20sp"
android:gravity="left"
>
</TextView>
<LinearLayout
android:id="@+id/widget42"
android:layout_width="fill_parent"
android:layout_height="2px"
android:orientation="vertical"
android:background="#88ffffff"
android:layout_marginBottom="10px"
/>
<CheckBox
android:id="@+id/set_auto_mark_cb"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Auto mark as read"
>
</CheckBox>
<CheckBox
android:id="@+id/set_auto_mark_cb12"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Auto mark as read"
>
</CheckBox>
<CheckBox
android:id="@+id/set_unread_cb"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Show unread only"
>
</CheckBox>
<CheckBox
android:id="@+id/set_skip_cb"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Mark as read on skip"
>
</CheckBox>
<TextView
android:id="@+id/set_click_tv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="On feed content click, do:"
android:typeface="serif"
android:textStyle="bold"
android:textSize="20sp"
android:layout_marginTop="10px"
>
</TextView>
<LinearLayout
android:id="@+id/widget41"
android:layout_width="fill_parent"
android:layout_height="2px"
android:orientation="vertical"
android:background="#88ffffff"
android:layout_marginBottom="10px"
/>
<Spinner
android:id="@+id/set_action_spin"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5px"
android:layout_marginBottom="5px"
android:layout_marginLeft="5px"
android:layout_marginRight="5px"
android:drawSelectorOnTop="true"
android:layout_gravity="center_horizontal"
>
</Spinner>
<TextView
android:id="@+id/set_account_tv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Change reader account:"
android:typeface="serif"
android:textStyle="bold"
android:textSize="20sp"
android:gravity="left"
android:layout_marginTop="10px"
>
</TextView>
<LinearLayout
android:id="@+id/widget42"
android:layout_width="fill_parent"
android:layout_height="2px"
android:orientation="vertical"
android:background="#88ffffff"
android:layout_marginBottom="10px"
/>
<Button
android:id="@+id/set_account_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Change">
</Button>
</LinearLayout>
</ScrollView>

Но если я добавлю еще один вид (CheckBox, TextView, LinearLayout) на этот макет (не в RunTime, в CodeTime, я не попытался сделать это в RunTime), когда я его открываю (setContentView (sv)), он говорит:

Окно уже сфокусировано, игнорируя усиление фокуса: com.android.internal.view.IInputMethodClient$Stub$Proxy@462fa1b0

Я могу изменить любой вид, но не могу добавить новый.

Это мой инфляционный код:

LayoutInflater inf = getLayoutInflater();
ScrollView sv = (ScrollView)inf.inflate(R.layout.layout_settings, null);
//More code here

Итак, есть ли максимум обзора, который может размещать ScrollView?

Так или иначе.

1 Ответ

1 голос
/ 02 марта 2011

Я не вижу проблем в наличии большего количества виджетов / компонентов внутри вашего LinearLayout.Насколько я знаю, единственным ограничением ScrollView является то, что у него должен быть только один ребенок.Почему ты раздуваешь макет?Вы можете просто использовать setContentView(R.layout.layout_settings).Я попробовал ваш XML-файл, и я могу добавить больше просмотров без проблем.

...