【问题标题】:android imageView scaleandroid imageView 比例
【发布时间】:2015-06-22 09:35:11
【问题描述】:

我有一个从数据库填充的 ImageView(图像来自数据库)。在数据库中我有肖像和风景的图像!如何根据图像的宽度和高度调整 imageView 以自行缩放。我尝试了很多方法,但没有结果!请有任何帮助!!!!

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <HorizontalScrollView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

        >

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/slideshow"
        android:orientation="horizontal"
        android:padding="0dp"
        >

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="300dp"
            android:layout_marginRight="5dp"
            android:id="@+id/slide1"
            android:src="@drawable/ddd"
            />

【问题讨论】:

  • 使用android:layout_width="wrap_content" android:layout_height="wrap_content"
  • 为什么RelativeLayout里面有LinearLayout?
  • 将 wrap_content 用于 relativelayout 和 imageview

标签: android imageview scale


【解决方案1】:

试试这个代码。 adjustViewBounds 属性使ImageView 与您放入其中的图像大小相同。

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:adjustViewBounds="true" />

如果您需要特定的width 或height,请更改wrap_content 值。

【讨论】:

  • Tanx 太多了,亲爱的 Max!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-10-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-08-23
  • 2015-10-30
相关资源
最近更新 更多