Tôi gặp sự cố khi hiển thị ScrollView. Về cơ bản, bố cục là đầu trang và chân trang cố định với một scrollview ở giữa. Ý tưởng là khi bàn phím màn hình được kích hoạt cho nội dung EditText, hình ảnh có thể được cuộn nếu chiều cao của hình ảnh dài hơn điểm giữa.Android ScrollView thêm phần đệm bổ sung vào hình ảnh thu nhỏ trên cùng và dưới cùng của hình ảnh con
Trong thử nghiệm bố cục, tôi thấy rằng trên điện thoại Android của tôi (Xperia X10 Android 1.6) có một đống đệm được thêm vào phần trên cùng và dưới cùng của ImageView.
Tôi đánh giá cao bất kỳ đề xuất nào về cách tôi có thể ngăn điều này xảy ra.
<?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>
Bất kỳ giải thích nào về lý do tại sao? –
Tôi gặp sự cố này trên RelativeLayout bên trong ScrollView. Đưa adjustmentViewBounds vào xml của tôi không giải quyết được. Có nguyên nhân cho việc này không? Tôi nhận thấy rằng phần đệm được thêm ở trên cùng là chiều cao của thanh trạng thái và phần đệm ở phía dưới có cùng chiều cao với thanh điều hướng –
Đã giúp tôi. Cảm ơn. – Gereltod