Kaopiz / android-segmented-control

ios UISegmentedControl for android
1.89k stars 397 forks source link

Removing dynamically #64

Open Westy-Dev opened 8 years ago

Westy-Dev commented 8 years ago

First of all - great library.

I have written code to remove (either by removeView or setVisibility(View.GONE) ), an element from the segmented group, but this causes a visual issue due to a segment being cut and the round edges not being re-added (far right element is removed in my case).

How can I go about adding the rounded closed edges back to this element?

Many thanks.

cnuland commented 8 years ago

I would also be curious how to do this.

nateridderman commented 8 years ago

+1

partyzan commented 7 years ago

Same for me, need dynamic control.

daordonez11 commented 7 years ago

Solved it today! You've got to use SegmentedGroup.removeView() after you remove each one of the radiobuttons you want out you call SegmentedGroup.updateBackground() this will solve this issue #

RyanPnayR commented 4 years ago

What ended up working for me was reseting the layout params for the other radio buttons after removing the last one.


SegmentedGroup.removeView(view3)
SegmentedGroup.updateBackground()
val layoutParams = RadioGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT, 1f)
view1.setLayoutParams(layoutParams)
view2.setLayoutParams(layoutParams)