【问题标题】:Image Size Vary in different Android Phone不同安卓手机的图片大小不同
【发布时间】:2014-05-03 04:56:27
【问题描述】:

您好,我正在从 Android 中的 URL 下载位图并将其设置为 imageview。奇怪的问题是,同一个位图在一部 Micromax Android 手机中看起来又好又大,而在索尼它的尺寸看起来非常小。

即使我将其宽度设置为fill_parent,但看到条形码看起来非常小

在一部手机中看起来不错,这两款手机的屏幕宽度相同。

<LinearLayout
    android:id="@+id/bottomLayout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/bottomLayoutofflipicon"
    android:layout_marginLeft="10dip"
    android:layout_marginRight="10dip"
    android:layout_marginTop="10dip"
    android:background="@drawable/rounded_corner2"
    android:gravity="center"
    android:orientation="vertical"
    android:padding="5dip" >

    <ImageView
        android:id="@+id/qrCode"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true" />

    <TextView
        android:id="@+id/barCodevaluetextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>

【问题讨论】:

  • android 中的缩放是基于分辨率的。您可以创建不同分辨率的位图并将它们放在各自的可绘制文件夹中,也可以手动处理缩放。
  • @zgc7009 我正在从 URL 下载位图,因此无法将它们放在相应的可绘制文件夹中,您能建议我如何手动处理这种缩放吗?

标签: android android-layout bitmap


【解决方案1】:

在您的ImageView 中,将android:layout_width 更改为android:layout_width="match_parent"

【讨论】:

  • 没有变化,还是一样
  • @Mick 实际上,尝试删除android:scaleType 并将android:adjustViewBounds="true" 放回去,这似乎对我有用。关键是设置宽度以匹配父级。
【解决方案2】:

只需采用大尺寸可绘制对象即可解决我的问题,并且我还使用 scaletype 到 centerInside。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-10
    • 1970-01-01
    • 2013-02-22
    相关资源
    最近更新 更多