ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

android-不缩放的ImageView

2019-11-23 09:25:23  阅读:321  来源: 互联网

标签:scaling imageview android


我有一个显示行的ListView

这是xml:

 ...
  <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="5dp"
        android:layout_weight="1"
        android:background="@color/white"
        android:orientation="vertical" >

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight=".30">

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:background="@drawable/face"
                android:scaleType="centerCrop" />
        </FrameLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight=".70"
            android:background="@color/white"
            android:padding="4dp" >

            // Other views...

        </LinearLayout>
    </LinearLayout>
    …

并得到以下结果:

这是原始图像

需要的是没有缩放的图像,就像这样:

我正在使用android:ScaleType =“ centerCrop”我在android上测试过:AdjustViewBounds =“ true”和许多其他参数,但从未成功

有想法吗?

提前致谢

解决方法:

将您的图片设置为android:src而不是android:background.

<ImageView
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:src="@drawable/face"
                android:scaleType="centerCrop" />

所有视图均可拍摄背景图像

ImageView的src具有其他功能:

>不同的scaling types
> AdjustViewBounds用于设置边界以匹配图像尺寸
>一些转换,例如alpha设置

您可能会在the docs中找到更多内容.

标签:scaling,imageview,android
来源: https://codeday.me/bug/20191123/2066739.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有