Padding in ImageView is not Working

前端 未结 3 726
隐瞒了意图╮
隐瞒了意图╮ 2021-02-18 23:24

I want to make a screen which contains a top bar and an image. I use TextView for the top bar and ImageView for the image. I want to set padding only to the image view. My xml i

3条回答
  •  一整个雨季
    2021-02-18 23:46

    On the ImageView use

    android:src="@drawable/image"
    

    instead of

    android:background="@drawable/image"
    

    src tag honors the padding whereas background tag does not. In some cases, esp. on clickable icon, it is a bad idea to use layout_margin instead of padding, as padding belongs to the view and makes the click area bigger!.

提交回复
热议问题