0

I have set dynamic width in drawer layout in android. I have all ready tried

 drawerlayout=findViewById(R.id.drawerlayout)
     rel_dynamic_size=findViewById(R.id.rel_dynamic_size);
     val width = resources.displayMetrics.widthPixels / 2
     val params: ViewGroup.LayoutParams? = rel_dynamic_size!!.getLayoutParams()
     params!!.width = width.toInt()
     rel_dynamic_size!!.setLayoutParams(params) 
MMG
  • 3,226
  • 5
  • 16
  • 43
  • Does this answer your question? [Android set navigation drawer list to open exact half of the screen for all device screen](https://stackoverflow.com/questions/21038058/android-set-navigation-drawer-list-to-open-exact-half-of-the-screen-for-all-devi) – Biscuit Mar 16 '20 at 14:19

1 Answers1

0
 drawerlayout=findViewById(R.id.drawerlayout)
 rel_dynamic_size=findViewById(R.id.rel_dynamic_size);

 val width = resources.displayMetrics.widthPixels / 1.8
 val params: ViewGroup.LayoutParams? = rel_dynamic_size!!.getLayoutParams()
 params!!.width = width.toInt()
 rel_dynamic_size!!.setLayoutParams(params)