LinearLayout: layout_gravity=“bottom” not working on Horizontal LinearLayout

前端 未结 7 913
青春惊慌失措
青春惊慌失措 2020-12-02 09:07

Ok, First of all, I searched all the internet, but nobody has a similar problem like this. So, all I want is to have 3 textViews, bottom aligned with the screen and with the

7条回答
  •  独厮守ぢ
    2020-12-02 09:53

    The Correct Answer

    All the other answers are wrong. The important points:

    1. You don't need RelativeLayout. You can do this with just a LinearLayout.
    2. (Not critical but I guess you didn't know) Your weights don't need to sum to 1, you can just set them all to any equal value (e.g. 1).
    3. The critical thing is you need android:baselineAligned="false". I actually only found this by looking through the LinearLayout source. It is in the docs but they don't mention that it is on by default!

    Anyway, here is the code:

    
    
          
    
          
    
    
          
    
     
    

    And how it looks:

    Good linear layout

提交回复
热议问题