【问题标题】:ImageView troubleImageView 问题
【发布时间】:2010-10-22 10:13:24
【问题描述】:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <ImageView              
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:src="@drawable/wallpaper" />
</RelativeLayout>

@drawable/peetscoffee_wallpaper 的大小是 640x480 ,但它不是水平居中的。 我该如何解决这个问题?

【问题讨论】:

    标签: android layout uiimageview


    【解决方案1】:

    尝试使用android:gravity="center"android:layout_gravity="center",而不是centerHorizontal="true"

    但是,我怀疑这对于大小设置为 wrap_content 的图像是否会表现得明智 - 您可能希望使用 android:scaleType 定义一些图像缩放方法(例如 fitCenter)并将其设置为 fill_parent 而不是wrap_content640x480 大于当前实际 Android 设备支持的 320x480。或者只是缩小您正在使用的图像,这样设备就不必完成这项工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-02-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多