简体   繁体   中英

How can I show these ListView items without the images being clipped?

I'm trying to create a ListView that contains a CheckBox and an ImageButton . So far, I have the following working, which is depicted below:

在此处输入图片说明

This is the layout of each ListView item:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/widget32"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <ImageButton
        android:id="@+id/imgTime"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/datetime"
        android:layout_alignBottom="@+id/rbOutput"
        android:layout_alignParentRight="true" />
    <CheckBox
        android:id="@+id/rbOutput"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="[User Output]"
        android:layout_centerVertical="true"
        android:layout_alignParentLeft="true" />
</RelativeLayout>

The problem is the image has the top and bottom clipped off. How can I show the full image and the checkbox to the left of it, vertically centered in each ListView item?

For reference, this is the complete unclipped image:

在此处输入图片说明

Add

android:scaleType="fitCenter"

to the xml definition for the image to Scale the image using CENTER

source

You can use several options of scaleType for ImageView ; here are the options and outputs of them respectively.

http://etcodehome.blogspot.com/2011/05/android-imageview-scaletype-samples.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM