I customize the button in Android, changing its background (using the 9patch png file) and changing the font of the font. I put the button in RelativeLayout, since I need the exact positioning and dimensions of this element in the custom layout. I do all this programmatically (from creation to customization and display).
I found this question with the same problem, but the solution for me will not work. I used
continueBtn.setPadding(0,0,0,0);
but the graphic output remains unchanged. More than half of the text is disabled in the view.
An excerpt from the code I'm using is as follows:
Button continueBtn = new Button(getContext());
p = new RelativeLayout.LayoutParams(width, 45);
p.addRule(CENTER_HORIZONTAL);
continueBtn.setLayoutParams(p);
continueBtn.setTypeface(...);
continueBtn.setTextSize(14);
outerLayout.addView(continueBtn);
continueBtn.setPadding(0, 0, 0, 0);
No matter where I place the method call setPadding, everything will not change. What am I doing wrong? Any ideas?
source
share