I am trying to make a scroll view that has a nested relativeLayout view. The realative layout has a background image. When the realativeLayout is the only layout the background image is the size I want it to be.
When I add scroll view it makes the image bigger and I am not sure why and what properties I need to set to开发者_C百科 fix it.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout android:id="@+id/mainLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/background2"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView android:id="@+id/txtApplicationTitle"
android:text="My Application"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_marginTop="5dp"
android:textSize="15dp"
android:layout_alignParentTop="true"
android:layout_alignLeft="@+id/txtAbout" />
<TextView android:id="@+id/txtPrivacyHeader"
android:layout_width="wrap_content"
android:text="@string/PrivacyHeader"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_marginLeft="21dp"
android:layout_marginTop="94dp" />
<TextView android:id="@+id/Privacy"
android:layout_width="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/Privacy"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/txtPrivacyHeader"
/>
</RelativeLayout>
</ScrollView>
// this is what I get (you can't tell but it is scrollable)

// this how I want the SrcollView to look(this is the exact same code as above just without the ScrollView wrapping it)

See how the top part has all of sudden grown so much.
Your ScrollView has its height set to wrap_content and your RelativeLayout has its height set to fill_parent. That means your ScrollView is going to expand to the entire view.
加载中,请稍侯......
精彩评论