Android: Center an image

前端 未结 13 1082
Happy的楠姐
Happy的楠姐 2020-12-07 17:38

I\'ve got a linear layout and an image...





        
13条回答
  •  一整个雨季
    2020-12-07 18:11

    First of all, you need to use 'match_parent' and don't use 'fill_parent' in the LinearLayout declaration, you could check the "official documentation" here https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html#MATCH_PARENT Another observation is that you need to use the ImageView as a child, then use ImageView should be self-closing; this means that it should end with '/>'. Then let me show you some fast ideas: 1- As natural way

     
    

    Then looks like 2- You could improvise fastly

    
    
    

    And then looks like

    3- Other ideas could be born in that way, for instance this one

     
     
    

    Lokking like this

    Other possibility

    
    
    

    As we have been seeing, you could use 'hidden spaces' or 'spaces with background color' to fastly solve some trouble, obviously, this is not always a possibility

提交回复
热议问题