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

前端 未结 7 957
青春惊慌失措
青春惊慌失措 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

    Ok. So I had the same issue, but with toggle buttons instead of text views. For some reason, if one of the elements in the LinearLayout(Horizontal) has a different height than the rest of the views in the layout and is set to have the same gravity as the others, the gravity is effectively "ignored".

    I managed to have the desired behavior by wrapping each view inside a RelativeLayout and set the android:gravity on the relative layout instead of android:layout_gravity on each button. I also moved the android:layout_weight from the button to the relative layout.

    So instead of having:

    
        
    
    
        
    
        
    
    

    Which gives the same problem as reported, I instead did:

    
        
    
            
    
        
    
                  
    
        
    
            
    
    

提交回复
热议问题