Unwanted padding around an ImageView

前端 未结 8 819
闹比i
闹比i 2020-12-02 05:20

I need to include a header graphic in all of my activities/views. The file with the header is called header.xml:



        
8条回答
  •  余生分开走
    2020-12-02 05:48

    It has to do with the image aspect ratio. By default, the system keeps the original aspect ratio of the image source. Which in most cases does not exactly match the layout or dimensions specified in the layout. Therefore,

    1. Either change the size of the image to fit the specified layout, or
    2. Use android:scaleType to fit the image. For example, you can specify android:scaleType="fitXY"

提交回复
热议问题