我在渲染ScrollView方面遇到了问题。实际上,布局是固定的页眉和页脚,中间有一个ScrollView。我的想法是当内容EditText激活屏幕键盘时,如果图像的高度超过了中间视图,那么图像可以滚动。
在测试布局时,我发现在我的Android手机(Xperia X10 Android 1.6)上,ImageView的顶部和底部都添加了大量的填充。
我希望能够得到任何建议,以防止这种情况发生。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- Header -->
<RelativeLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF">
<TextView
android:text="Share your photo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"/>
<Button
android:id="@+id/btnStack"
android:text="Stacks"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"/>
</RelativeLayout>
<!-- End Header -->
<!-- Body -->
<ScrollView
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="5px"
android:background="#CCCCCC">
<ImageView
android:id="@+id/imgPreview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</ScrollView>
<!-- End Body -->
<!-- Footer -->
<RelativeLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:layout_alignParentBottom="true">
<EditText
android:id="@+id/caption"
android:text="Type your caption"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/caption"
android:background="#CCCCCC">
<Button
android:id="@+id/btnUpload"
android:text="Share"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<Button
android:id="@+id/btnCancel"
android:text="Cancel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>
</RelativeLayout>
<!-- End Footer -->
</LinearLayout>