Issue
First 5 buttons are added programatically and last one via XML. Both ways I use same parameters. Why are dynamically added buttons text's cut off?
Programatic:
Button b = new Button(getActivity());
b.setText(text);
b.setAllCaps(false);
b.setBackgroundResource(R.drawable.button_tag_rect);
b.setTextColor(getResources().getColor(R.color.colorWhiteText));
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
dpToPx(28));
int marginInPx = dpToPx(2);
params.setMargins(marginInPx, marginInPx, marginInPx, marginInPx);
tagCloudTwitter.addView(b, tagCloudTwitter.getChildCount()-1, params);
XML:
<Button
android:layout_width="wrap_content"
android:layout_height="28dp"
android:layout_margin="2dp"
android:textAllCaps="false"
android:background="@drawable/button_tag_rect"
android:textColor="@color/colorWhiteText"
android:text="test"/>
EDIT: solved! See my answer bellow.
Solution
Funnily enough, what helped was setting a "dummy" padding:
b.setPadding(1,1,1,1);
¯\_(ツ)_/¯
Answered By - c0dehunter
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.