How to size image to its original size

ぐ巨炮叔叔 提交于 2019-12-02 19:04:21

问题


Android's imageView has a serious flaw: it makes my image into a square frame, with the rest as white space. How can I fix this? I have tried scale type, but it didn't work. Thank you.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:contentDescription="@string/header"
        android:scaleType="fitStart"
        android:src="@drawable/img_001" />

</RelativeLayout>


回答1:


Without your code I can only guess, but I suggest that you add either the xml attribute android:adjustViewBounds="true" or in your activity, give the imageview that attribute with imageView.setAdjustViewBounds(true)



来源:https://stackoverflow.com/questions/20827672/how-to-size-image-to-its-original-size

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!