How do I remove extra space above and below imageView?

后端 未结 11 1510
别跟我提以往
别跟我提以往 2020-12-08 05:57

I have a really simple image within a RelativeLayout and for some reason I am getting extra spacing on the top and bottom which I can\'t remove. How can I clear

相关标签:
11条回答
  • 2020-12-08 06:42

    If your image view height is match_parent, even if you set android:adjustViewBounds="true" ImageView will add some extra blank space at top and bottom side. so, change ImageView height to wrap_content and set android:adjustViewBounds="true"

    for example

    <ImageView
      android:id="@+id/img_view"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:adjustViewBounds="true"/>
    
    0 讨论(0)
  • 2020-12-08 06:44

    Try this

    <ImageView
         (...)
         android:adjustViewBounds="true" />
    
    0 讨论(0)
  • 2020-12-08 06:45

    android:scaleType="centerCrop" by adding this

    <ImageView
        android:id="@+id/image"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:src="@drawable/temp_image"
        android:adjustViewBounds="true"
        android:scaleType="centerCrop"/>
    

    works for me Before and After Image

    0 讨论(0)
  • 2020-12-08 06:49

    Try this

    android:adjustViewBounds="true"

    0 讨论(0)
  • 2020-12-08 06:51

    this line of code will solve the problem

    android:adjustViewBounds="true"
    

    don't forget to rotate the image

    0 讨论(0)
提交回复
热议问题