Я хочу добавить ScrollView в следующий файл xml_layout. Но у меня немного проблем.
Хорошо, поэтому я исследовал это и обнаружил, что, изменив "LinearLayout xmlns: android =" http://schemas.android.com/apk/res/android" на ScrollView ... Я получаю страшное "ScrollView может содержать только одного прямого дочернего элемента". Поэтому я оборачиваю все в LinearLayout, и моя ошибка исчезает. ScrollView работает сейчас, однако я теряю все после моего первого TableLayout. Я не понимаю, почему.
Хотя "да" я хочу получить ответ, я также хочу знать, почему это происходит.
Я изменяю первый LinearLayout и соответствующий тег на Scrollview. Затем добавьте LinearLayout прямо под ScrollView и закройте его прямо над закрывающим ScrollView, который является последним тегом.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:stretchColumns="0" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="25dp" >
<EditText
android:id="@+id/edit_input"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="Canton, Ohio" />
<Button
android:id="@+id/cmd_submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="OK" />
</TableRow>
<TableRow >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Input like: 'City, State' or ZIP" />
</TableRow>
</TableLayout>
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:stretchColumns="0" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:paddingLeft="50dp">
<CheckBox
android:id="@+id/chk_usecelsius"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Use °C (not °F)"
/>
</TableRow>
</TableLayout>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Current Tempature"
android:textSize="30dp" />
<com.kickintheapp.PapaStew.views.SingleWeatherInfoView
android:id="@+id/weather_today"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:paddingTop="15px"
android:paddingBottom="15px" />
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:stretchColumns="0" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</TableRow>
</TableLayout>
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="15px"
android:stretchColumns="0,1,2,3" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<com.kita.PapaStew.views.SingleWeatherInfoView
android:id="@+id/weather_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical" />
<com.kita.PapaStew.views.SingleWeatherInfoView
android:id="@+id/weather_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical" />
<com.kita.PapaStew.views.SingleWeatherInfoView
android:id="@+id/weather_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical" />
<com.kita.PapaStew.views.SingleWeatherInfoView
android:id="@+id/weather_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical" />
</TableRow>
</TableLayout>