android: stretch image in imageview to fit screen

后端 未结 9 1050
一向
一向 2020-12-02 05:37

I have an imageview that has its height and width set to fill_parent with a linearlayout that has the same values set. So I suppose th

相关标签:
9条回答
  • 2020-12-02 06:04

    I Have used this android:scaleType="fitXY" code in Xml file.

    0 讨论(0)
  • 2020-12-02 06:07

    The accepted answer is perfect, however if you want to do it from xml, you can use android:scaleType="fitXY"

    0 讨论(0)
  • 2020-12-02 06:09

    just change your ImageView height and width to wrap_content and use

    exampleImage.setScaleType(ImageView.ScaleType.FIT_XY);

    in your code.

    0 讨论(0)
  • 2020-12-02 06:11

    for XML android

    android:src="@drawable/foto1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scaleType="centerCrop"
    
    0 讨论(0)
  • 2020-12-02 06:13

    Trying using :

    imageview.setFitToScreen(true);
    imageview.setScaleType(ScaleType.FIT_CENTER);
    

    This will fit your imageview to the screen with the correct ratio.

    0 讨论(0)
  • 2020-12-02 06:14

    to change pro-grammatically use :

    imgview.setScaleType(ScaleType.FIT_XY);
    

    OR

    to change from xml use:

     android:scaleType="fitXY"
    
    0 讨论(0)
提交回复
热议问题