Android - 显示图像以适应设备的宽度
Android - Display image to fit width of device
我正在开发一个 android 应用程序,可以在列表视图中显示一些照片。
这是列表视图中每个项目的布局。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/exam_page_item_imageview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"/>
</RelativeLayout>
我的列表视图显示
我想显示适合设备宽度的图像视图。 (仅适合宽度)
你能给我建议或有什么想法可以解决这个问题吗?
试试这个:
<ImageView
android:id="@id/imgview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitCenter" />
android:adjustViewBounds = "true"
当您的图像大于 imageview 时会有帮助。它不会拉伸图像但会缩小图像。
android:scaleType="fitCenter"
当您的图片小于 imageview 时,它会将图片拉伸到其父级的宽度。
我正在开发一个 android 应用程序,可以在列表视图中显示一些照片。 这是列表视图中每个项目的布局。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/exam_page_item_imageview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"/>
</RelativeLayout>
我的列表视图显示
我想显示适合设备宽度的图像视图。 (仅适合宽度)
你能给我建议或有什么想法可以解决这个问题吗?
试试这个:
<ImageView
android:id="@id/imgview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitCenter" />
android:adjustViewBounds = "true"
当您的图像大于 imageview 时会有帮助。它不会拉伸图像但会缩小图像。
android:scaleType="fitCenter"
当您的图片小于 imageview 时,它会将图片拉伸到其父级的宽度。