我为布局保留了标题图片,当我滚动页面时,顶部标题栏图片也向上滚动。我想要保持该图像固定在顶部,以便即使在滚动之后,只有内容应滚动而不是图像。如何解决这个问题?请帮我解决这个问题?
我的布局文件:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget44"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="none"
android:background="#FFFFFF"
>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:background="#FFFFFF"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/topbar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/ins1"
>
<TextView
android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="60dip"
android:text=""
android:layout_marginLeft="23dip"
android:textSize="8pt"
android:textColor="#000000"
android:layout_alignParentLeft="true"
>
</TextView>
<TextView
android:id="@+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/text1"
android:layout_marginTop="10dip"
android:text=""
android:layout_marginLeft="23dip"
android:textSize="8pt"
android:textColor="#000000"
android:layout_alignParentLeft="true"
>
</TextView>
</RelativeLayout>
</RelativeLayout>
</ScrollView>
先谢谢
答案 0 :(得分:1)
我认为您应该将自己的<{1}}
的外部放在之外<ScrollView>
答案 1 :(得分:1)
将您的标题设置在scrollview之外,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android
android:id="@+id/widget44"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="none"
android:background="#FFFFFF">
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:background="#FFFFFF"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<!--Contents of title bar-->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget44"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="none"
android:background="#FFFFFF"
>
<!--Contents of scroll view--!>
</ScrollView>
</LinearLayout>
答案 2 :(得分:0)
将顶部栏布局移到滚动视图之外,并将这些2放在LinearLayout中,如下所示。
<?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" >
<RelativeLayout
android:id="@+id/topbar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/ins1" >
<TextView
android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="23dip"
android:layout_marginTop="60dip"
android:text=""
android:textColor="#000000"
android:textSize="8pt" >
</TextView>
<TextView
android:id="@+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/text1"
android:layout_marginLeft="23dip"
android:layout_marginTop="10dip"
android:text=""
android:textColor="#000000"
android:textSize="8pt" >
</TextView>
</RelativeLayout>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget44"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:scrollbars="none" >
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:orientation="vertical" >
//set the data for scrolling
</RelativeLayout>
</ScrollView>
</LinearLayout>