• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Android: calling setPadding() on a view doesn't work when I also set the layoutParams on the view

Meeks91

Lurker
If I call setPadding() on a view, I can successfully set the padding, however, if I first set the layoutParams and then the padding, or set the padding and then set the layoutParams, the padding is not applied.

Demonstration:

//This doesn't work
textView.setLayoutParams(linearLayoutParams);
textView.setPadding(0, 100, 0 , 0);

//This doesn't work either
testView.setPadding(0, 100, 0 , 0);
textView.setLayoutParams(linearLayoutParams);

//This does work
textView.setPadding(0, 100, 0 , 0);​


Does anyone know how to use setLayoutParams() and setPadding() at the same time, or why setLayoutParams() is stopping setPadding() from working?
 
Back
Top Bottom