MaterialDesignLibrary
MaterialDesignLibrary copied to clipboard
How I can change the textsize in button??
How I can change the text size in button??
ButtonRectangle extends Button, but you cannot access TextView using buttonRectangle.getTextView(), this will only get you a null object. The author creates a private field (TextView)textButton instead of using Button.getTextView(), so you can only get this field using Java Reflection. Here is my solution:
ButtonRectangle buttonRectangle = (ButtonRectangle) this.findViewById("YOUR BUTTON RESOURCE ID");
try {
Field textButton = buttonRectangle.getClass().getDeclaredField("textButton");
textButton.setAccessible(true);
//Here you can get the textview, then you can do whatever you want
TextView textView = (TextView) textButton.get(registerButton);
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
你是中国人吗?。。英文不错!谢了
But I use the Flat Button, does it as same as the ButtonRectangle?
@sousuo28 Thank you!, that helped me to change the text color from the rectangle button.