I am trying to dynamically add buttons to an activity based on how wide a device's screen is. When I use getApplicationContext().getResources().getDisplayMetrics().widthPixels
the returned value seems to be too large because buttons I attempt to draw at the edge are getting cut off. I tried getting the width of the layout but that returns 0. Any ideas on what I'm doing wrong would be appreciated. Thanks
Asked
Active
Viewed 50 times
-2

M. Rogers
- 367
- 4
- 18
1 Answers
0
My problem was with the padding, I didn't account for it. When I went into the XML and set the padding to 0, it fixed my problem.

M. Rogers
- 367
- 4
- 18