I have a simple question: how to get layout_weight programmatically? I saw a lot of topics when some Layoute set layout_weight, but how to get it?
Get LinearLayout.LayoutParamsfrom getLayoutParams()to Viewwhose parent is LinearLayout. The object LayoutParamshas a field weight.
LinearLayout.LayoutParams
getLayoutParams()
View
LinearLayout
LayoutParams
weight
this is the answer:
((LinearLayout.LayoutParams)yourView.getLayoutParams()).weight
this value will return the weight of your View to you and notice that your view should be in linear mode and have a weight of up to