android-flowlayout
android-flowlayout copied to clipboard
failed to set margins in between two items of flow layout its displaying continuously with no margins , padding ?
<org.apmem.tools.layouts.FlowLayout android:id="@+id/flowlayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="13dp" android:layout_marginRight="13dp" android:layout_below="@+id/relLayoutSpinner"> </org.apmem.tools.layouts.FlowLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/relativeLayout" android:orientation="vertical" android:layout_width="wrap_content" android:layout_marginLeft="13dp" android:layout_marginRight="13dp" android:layout_marginTop="5dp" android:layout_height="wrap_content" android:background="#0fb1fa"> <TextView android:id="@+id/txtViewFilterSelected" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:layout_centerVertical="true" android:layout_alignParentLeft="true" android:padding="5dp" android:textSize="16sp" android:layout_marginTop="5dp" style="@style/LatoBoldStyle" android:textColor="#ffffff" android:text="Sample Text"/> <ImageView android:id="@+id/imgCancel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@+id/txtViewFilterSelected" android:layout_centerVertical="true" android:layout_marginRight="10dp" android:layout_marginLeft="10dp" android:layout_marginTop="10dp" android:padding="10dp" android:src="@drawable/cross"/> </RelativeLayout>
any solution??
I'm adding margins programmatically to the FlowLayout children's and it's not working.
final FlowLayout layout = new FlowLayout(this); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); params.setMargins(20, 20, 20, 0);
//Creating TextView TextView txt = new TextView(this); txt.setText("test"); layout.addView(txt, params);
Any solution?
You need to use FlowLayout.LayoutParams
Like this:
FlowLayout.LayoutParams params = new FlowLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
Using FlowLayout.LayourParams
did the trick for me! I was using LinearLayout.LayoutParms
too and it didn't work. Thanks!