ScrollView 有时会切掉上部的一部分

ScrollView cuts out part of upper portion at times

我从其他开发人员那里购买的代码有问题。有一个显示图像和一些文本的滚动视图...

现在的问题是,如果图片后面的文字(引述)太大,图片的上半部分就会被剪掉...

这个问题到底是什么,抱歉,我"m unable to define this problem more generically, but I"我确定有一种通用的方法可以重写这个问题来帮助所有人...

谢谢

XML 下面:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/RelativeLayout1"
android:layout_width="wrap_content"
android:layout_height="360dp"
android:background="@drawable/background" >

<LinearLayout
    android:id="@+id/titleBar"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:layout_alignParentTop="true"
    android:background="@drawable/title_bar"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/iconImg"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:layout_gravity="center"
        android:layout_margin="5dip"
        android:background="@drawable/app_icon" />

    <ImageView
        android:id="@+id/titleImg"
        android:layout_width="140dp"
        android:layout_height="40dp"
        android:layout_gravity="center"
        android:layout_margin="5dip"
        android:background="@drawable/title" />

    <RelativeLayout
        android:id="@+id/closeBtn"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:paddingRight="2dip" >

        <ImageButton
            android:id="@+id/close"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:background="@drawable/button_clicked"
            android:scaleType="fitXY"
            android:src="@drawable/close" />
    </RelativeLayout>
</LinearLayout>

<View
    android:id="@+id/topShadow"
    android:layout_width="fill_parent"
    android:layout_height="5dip"
    android:layout_below="@id/titleBar"
    android:background="@drawable/shadow" >
</View>

<ScrollView
    android:id="@+id/scrollView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/bottomShadow"
    android:layout_below="@+id/topShadow" >

    <LinearLayout
        android:id="@+id/quote"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="6dp"
        android:orientation="vertical"
        android:padding="3dp" >

        <LinearLayout
            android:id="@+id/thumbnail"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:background="@drawable/image_bg"
            android:padding="3dp" >

            <ImageView
                android:id="@+id/picture"
                android:layout_width="100dp"
                android:layout_height="100dp" />
        </LinearLayout>

        <TextView
            android:id="@+id/text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal|center"
            android:fontFamily="lucida grande"
            android:gravity="center"
            android:text="In order to succeed ..."
            android:textColor="#FFF"
            android:textSize="22sp" />

        <TextView
            android:id="@+id/author"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="right"
            android:layout_marginRight="10dp"
            android:fontFamily="lucida grande"
            android:text="- Bill Gates"
            android:textColor="#e8d8a7"
            android:textSize="14sp" />
    </LinearLayout>
</ScrollView>

<View
    android:id="@+id/bottomShadow"
    android:layout_width="fill_parent"
    android:layout_height="2dip"
    android:layout_above="@+id/buttons"
    android:background="@drawable/shadow" >
</View>

<LinearLayout
    android:id="@+id/buttons"
    android:layout_width="match_parent"
    android:layout_height="60dp"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:background="@drawable/title_bar"
    android:orientation="horizontal" >

    <RelativeLayout
        android:id="@+id/favorite"
        android:layout_width="wrap_content"
        android:layout_height="60dp"
        android:layout_weight="1" >

        <ImageButton
            android:id="@+id/star"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:layout_marginLeft="4dp"
            android:background="@drawable/star_on" />
    </RelativeLayout>

    <View
        android:id="@+id/divider"
        android:layout_width="1dp"
        android:layout_height="match_parent"
        android:layout_below="@+id/titleBar"
        android:background="#000" />

    <RelativeLayout
        android:id="@+id/actionItems"
        android:layout_width="wrap_content"
        android:layout_height="60dp"
        android:layout_weight="1" >

        <ImageButton
            android:id="@+id/share"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:layout_marginRight="4dp"
            android:background="@drawable/share_button" />
    </RelativeLayout>
</LinearLayout>

试试这个:

<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/bottomShadow"
android:layout_below="@+id/topShadow" >

<RelativeLayout 
    android:id="@+id/quote"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_marginTop="6dp"
    android:orientation="vertical"
    android:padding="3dp" >

    <LinearLayout
        android:id="@+id/thumbnail"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:background="@drawable/image_bg"
        android:padding="3dp" >

        <ImageView
            android:id="@+id/picture"
            android:layout_width="100dp"
            android:layout_height="100dp" />
    </LinearLayout>

    <TextView
        android:id="@+id/text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
       android:layout_gravity="center_horizontal|center"
        android:fontFamily="lucida grande"
        android:gravity="center"
        android:text="In order to succeed ..."
        android:textColor="#FFF"
        android:textSize="22sp"
        android:layout_below:"@+id/thumbnail" />

    <TextView
        android:id="@+id/author"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="right"
        android:layout_below="@+id/text"
        android:layout_marginRight="10dp"
        android:fontFamily="lucida grande"
        android:text="- Bill Gates"
        android:textColor="#e8d8a7"
        android:textSize="14sp" />
</LinearLayout>

我能够通过从 ImageView

中删除 "Center" 属性来解决这个问题
       android:layout_gravity="center"