Padding in ImageView is not Working

前端 未结 3 716
隐瞒了意图╮
隐瞒了意图╮ 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:49

    You should use layout_margin instead of padding so it should be as following:

    
    
    
    
    
    

    and you can specify 1 layout_margin for all directions so instead of using

    android:layout_marginLeft="10dp"
    android:layout_marginTop="10dp"
    android:layout_marginRight="10dp"
    android:layout_marginBottom="10dp"
    

    you can use:

    android:layout_margin="10dip"
    

    hope this is what you are looking for. give me a feedback otherwise ;)

    update

    you can set cropToPadding also:

提交回复
热议问题