有時我們在頁面裡放的內容,有可能會超過頁面所能承載,這時就必須用到第二個頁面來顯示.
但你可以試試,android就只顯示第一個頁面,其他的內容你是看不到的.
那怎麼解決呢??
解決方法就是在你的Layout外面再套一層ScrollView
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_height="match_parent"> 中間放你原來的Layout </ScrollView>
隨便找了一段例子如下
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<GridLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:columnCount="2"
android:id="@+id/gridlayout"
android:rowCount="9"
android:touchscreenBlocksFocus="false"
android:useDefaultMargins="false">
<TextView
android:id="@+id/countrylabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/countrylabel"
android:textSize="18dp"
android:background="#d3ffb9"
/>
<TextView
android:id="@+id/country"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/countrylabel"
android:layout_gravity="left"
android:textSize="18dp"
android:background="#d3ffb9"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/tel"
android:layout_row="2"
android:layout_column="1"
android:textSize="16dp"
android:background="#d3ffb9"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="@string/opentimelabel"
android:id="@+id/textView"
android:layout_row="3"
android:layout_column="0"
android:textSize="16dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/opentime"
android:layout_row="3"
android:layout_column="1"
android:layout_gravity="left"
android:textSize="16dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="@string/thresholdlabel"
android:id="@+id/textView2"
android:layout_row="4"
android:layout_column="0"
android:textSize="16dp"
android:layout_columnSpan="2"
android:layout_gravity="center_horizontal" />
<TextView
android:id="@+id/populationlabel"
android:text="@string/populationlabel"
android:layout_row="1"
android:layout_column="0"
android:textSize="16dp"
/>
<TextView
android:id="@+id/population"
android:layout_row="1"
android:layout_column="1"
android:layout_gravity="left"
android:textSize="16dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/tellabel"
android:id="@+id/tellabel"
android:layout_row="2"
android:layout_column="0"
android:textSize="16dp"
android:background="#d3ffb9"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/toldescribe"
android:layout_row="5"
android:layout_column="0"
android:layout_gravity="left"
android:layout_columnSpan="2"
android:textSize="16dp"/>
<ImageView
android:id="@+id/flag"
android:layout_width="320dp"
android:layout_height="240dp"
android:layout_alignParentRight="false"
android:background="#FFFFFF"
android:padding="1dp"
android:layout_below="@+id/populationlabel"
android:layout_alignParentLeft="true"
android:adjustViewBounds="false"
android:layout_columnSpan="2"
android:layout_column="0"
android:layout_row="6"
android:layout_gravity="center_horizontal" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_row="7"
android:layout_column="0"
android:layout_columnSpan="2"
android:gravity="center">
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/btnRtn"
android:id="@+id/btnReturn"
android:layout_alignParentTop="true"
android:textSize="8dp"
android:padding="-20dp"
android:layout_row="7"
android:layout_column="0"
android:layout_columnSpan="2" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/btnMap"
android:id="@+id/btnMap"
android:layout_alignTop="@+id/btnReturn"
android:textSize="8dp"
android:padding="1dp"
android:layout_row="7"
android:layout_column="2" />
</LinearLayout>
</GridLayout>
</ScrollView>
文章標籤
全站熱搜