FlowLayout
FlowLayout copied to clipboard
Right side getting cut off
I am using the FlowLayout in a ScrollView and the right side of the layout is getting cut off. Not sure if this is related it to being in a ScrollView or not.
The last entry is getting cut off too.
I am programmatically adding TextViews to the FlowLayout:
private void updateMoviesTvTags() {
moviesTvContainer.removeAllViews();
for (int i = 0; i < 50; i++) {
CustomTextView tag = new CustomTextView(getActivity());
FlowLayout.LayoutParams lp = new FlowLayout.LayoutParams(FlowLayout.LayoutParams
.WRAP_CONTENT, FlowLayout.LayoutParams.WRAP_CONTENT);
lp.setMargins(0, 0, 10, 10);
tag.setLayoutParams(lp);
tag.setBackground(getResources().getDrawable(R.drawable.tag_bg));
tag.setText("test");
tag.setTextSize(16);
tag.setTextColor(getResources().getColor(R.color.primary_blue));
tag.setPadding(10, 10, 10, 10);
moviesTvContainer.addView(tag);
}
}
<com.wefika.flowlayout.FlowLayout
android:id="@+id/movies_tv_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start|top"
android:padding="10dp"/>
Try adding margin for all sides : Change your line from lp.setMargins(0, 0, 10, 10); to lp.setMargins(10, 10, 10, 10);
Could it be that you set padding in your XML-Layout? I got the same problem if I add padding to the FlowLayout. Without the padding everything is working correctly.