我想讓中間部分滾動。我無法得知任何想法..這是我的XML大綱。我想在可滾動區域插入這個XML大綱。
注意:頁眉和頁腳必須保持不變。只有中部地區的要滾動
我想讓中間部分滾動。我無法得知任何想法..這是我的XML大綱。我想在可滾動區域插入這個XML大綱。
注意:頁眉和頁腳必須保持不變。只有中部地區的要滾動
更簡單的方法是使用:
<RelativeLayout 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"
tools:context=".MainActivity" >
<LinearLayout
android:id="@+id/headerView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" >
</LinearLayout>
<ScrollView
android:id="@+id/scrollablContent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/footerView"
android:layout_below="@+id/headerView" >
<LinearLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="@+id/footerView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
</LinearLayout>
</RelativeLayout>
你必須從LinearLayout中更換外部容器的RelativeLayout,然後設置的alignParentTop =真對於ScrollView,頁眉ImageView,alignParentBottom = true爲頁腳ImageView,並設置layout_above =「@ + id/imageViewFooter」,layout_below =「@ + id/imageViewHeader」。像這樣:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/imageViewHeader"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="false"
android:layout_alignParentTop="false"
android:scaleType="fitXY"
android:src="@drawable/square" />
<ImageView
android:id="@+id/imageViewFooter"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
android:scaleType="fitXY"
android:src="@drawable/square" />
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/imageViewFooter"
android:layout_below="@+id/imageViewHeader" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
如何設置這個'android:scaleType =「fitXY」'和'android:src =「@ drawable/square」' – DroidLearner
MyBAD !!我知道了.. fitXY – DroidLearner
是什麼意思fitXY只是告訴ImageView圖像必須符合強加的尺寸,而不考慮比例。 – moondroid
它不工作 – DroidLearner
它只是一個示例,您必須將您的小部件添加到特定的組視圖,例如您的頭部必須添加到LinearLayout headerView。 –
好吧!!!!!!!!! – DroidLearner