Closed YKW93 closed 5 years ago
Sorry, could you provide more details or some image visualization that will show how you want to position segment items
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginBottom="10dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:background="@android:color/white">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
android:textSize="16sp"
android:text="변속기"/>
<segmented_control.widget.custom.android.com.segmentedcontrol.SegmentedControl
android:id="@+id/seg_transmission_control"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
app:columnCount="4"/>
</LinearLayout>
(segment item xml code) <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="5dp">
<RelativeLayout
android:layout_width="65dp"
android:layout_height="65dp">
<com.aby.lib.widget.CircleImageView
android:id="@+id/civ_fuel_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:border_color="@color/color_ff4d4d4d"
app:border_width="1dp"
android:layout_centerInParent="true"
android:src="@android:color/white"/>
<TextView
android:id="@+id/tv_fuel_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:textColor="@color/color_ff4d4d4d"
android:textSize="14sp"
android:text="하이\n브리드"/>
<RelativeLayout
android:id="@+id/rl_check_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="invisible"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginBottom="2dp"
android:layout_marginEnd="2dp">
<com.aby.lib.widget.CircleImageView
android:layout_width="15dp"
android:layout_height="15dp"
android:src="@color/colorPrimary"/>
<ImageView
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_centerInParent="true"
android:src="@drawable/check"/>
</RelativeLayout>
</RelativeLayout>
I want to give you the same margin on both ends of the item.
Use this properties from xml or programmatically app:segmentVerticalMargin="16dp" app:segmentHorizontalMargin="16dp"
<segmented_control.widget.custom.android.com.segmentedcontrol.SegmentedControl
android:id="@+id/sc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:segmentVerticalMargin="16dp"
app:segmentHorizontalMargin="16dp" />
And from your view holder inside onSegemtnBind() method apply this margins to your segments civ_fuel_image
((ViewGroup.MarginLayoutParams) civ_fuel_image.getLayoutParams()).setMargins(getSegmentHorizontalMargin(), getSegmentVerticalMargin(), getSegmentHorizontalMargin(), getSegmentVerticalMargin());
As you have created your own implementation of SegmentViewHolder you need to handle the attributes yourself. look at SegmentViewHolderImp.java file, it will help you to implement segment attributes
is this issue resolved ?
yes sure. so thx.
I want to apply center_horizontal to items.
How should it be applied?