Tôi đang sử dụng relativelayout để phủ lên hình ảnh. Trên tất cả các kích cỡ màn hình mà tôi đã thử nghiệm (từ 2,7 đến 10,1 inch), tôi luôn có được khoảng trắng ở phía trên hình ảnh của mình. Trong IDE của tôi, tôi luôn thấy rằng relativelayout của tôi đang gây thêm không gian trên đầu và ở dưới cùng của hình ảnh của tôi.Tại sao tôi nhận được khoảng trắng ở trên cùng và ở dưới cùng của ImageView trong RelativeLayout của tôi?
Tại sao lại như vậy? Tôi đã đặt tất cả các thuộc tính độ cao thành wrap_content
và thậm chí đã thêm thuộc tính adjustViewBounds
.
Lưu ý: Bạn nên biết rằng hình ảnh của tôi có kích thước lớn hơn rất nhiều, có nghĩa là sẽ có một số loại tỷ lệ.
Cảm ơn lời khuyên của bạn!
Đây là mã:
<?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="wrap_content"
android:background="#FFFFFF"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical"
android:focusable="true"
android:focusableInTouchMode="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/bgf"
android:textColor="#000000"
android:textSize="25sp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:paddingRight="5dp"
android:paddingLeft="5dp"
android:paddingBottom="5dp"
android:layout_gravity="center_horizontal"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:src="@drawable/cde"
android:contentDescription="@string/cde" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:layout_gravity="center_horizontal"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:src="@drawable/fgh"
android:contentDescription="@string/abc" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
scrollview bạn chỉ nên có một đứa trẻ. Relativelayout của bạn có nằm trong chế độ xem cuộn không? – Neoh
Bạn có thể đăng hình ảnh bố cục –
@Neoh không có mã nào bị thiếu. kiểm tra lại một lần nữa – user2426316