Change Guideline percentage in constraint layout programmatically

后端 未结 6 1145
你的背包
你的背包 2021-02-04 23:25

I have a guideline in constraint layout like this



        
6条回答
  •  死守一世寂寞
    2021-02-05 00:28

    In Kotlin & inside Fragment or other activities,set GuideLine app: related parameters has a little difficulty , but I Solved it in this way :

     val view = inflate(this, R.layout.ly_custom_menu_item_wallet_side_menu, null)
     val guideL = view.findViewById(R.id.guideline_wallet)
              var constParam: ConstraintLayout.LayoutParams = guideL.layoutParams as ConstraintLayout.LayoutParams
              constParam.guidePercent = 0.42f
              guideL.layoutParams = constParam
    

    and this is Guideline element inside our ly_custom_menu_item_wallet_side_menu.xml layout :

     
    

提交回复
热议问题