Get LinearLayout Gravity

后端 未结 3 1460
一整个雨季
一整个雨季 2020-12-21 07:13

I was needing to get the value of the gravity of a LinearLayout. I checked the documentation and I only found how to set it ( setGravity(value) ).

3条回答
  •  一生所求
    2020-12-21 07:31

    You should get it from the LayoutParams of the LinearLayout:

    mLinearLayout.getLayoutParams().gravity
    

    @see doc of LinearLayout.LayoutParams:

    public int  gravity Gravity for the view associated with these LayoutParams.
    

提交回复
热议问题