我想让中间部分滚动。我无法得知任何想法..这是我的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