SegmentedButton icon indicating copy to clipboard operation
SegmentedButton copied to clipboard

After first clicked, Selector becomes smaller

Open TonyNikolov opened this issue 7 years ago • 1 comments

Hello, i am using 1.2.2 When i start the activity the selector looks fine, but when i click the button or the segmented group itself, it becomes smaller and it doesnt fill the buttons.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#b6a5a5" android:orientation="vertical">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:orientation="horizontal">

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_marginEnd="10dp"
        android:layout_marginRight="10dp"
        android:text="Position: 1"/>

    <co.ceryle.segmentedbutton.SegmentedButtonGroup
        android:id="@+id/segmentedButtonGroup"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_margin="4dp"
        android:elevation="2dp"
        app:sbg_backgroundColor="#F00"
        app:sbg_dividerColor="#FFF"
        app:sbg_dividerPadding="10dp"
        app:sbg_dividerRadius="10dp"
        app:sbg_dividerSize="12dp"
        app:sbg_position="0"
        app:sbg_radius="2dp"
        app:sbg_rippleColor="#F35"
        app:sbg_selectorColor="#0F0">

        <co.ceryle.segmentedbutton.SegmentedButton
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            app:sb_text="Button 1"/>

        <co.ceryle.segmentedbutton.SegmentedButton
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            app:sb_text="Button 2"/>

        <co.ceryle.segmentedbutton.SegmentedButton
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            app:sb_text="Button 3"/>
    </co.ceryle.segmentedbutton.SegmentedButtonGroup>

</LinearLayout>
package com.whatrecipes.dnt.whatrecipes.activities;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.whatrecipes.dnt.whatrecipes.R;

import co.ceryle.segmentedbutton.SegmentedButtonGroup;

public class ActivityTest extends AppCompatActivity {

    private Button button;
    private SegmentedButtonGroup group;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test);

        group = (SegmentedButtonGroup) findViewById(R.id.segmentedButtonGroup);
        button = (Button) findViewById(R.id.button);

        updateButton(group.getPosition());

        group.setOnClickedButtonPosition(new SegmentedButtonGroup.OnClickedButtonPosition() {
            @Override
            public void onClickedButtonPosition(int position) {
                Toast.makeText(ActivityTest.this, "Clicked: " + position, Toast.LENGTH_SHORT).show();
            }
        });


        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                int position = group.getPosition();
                position = ++position % 3;
                updateButton(position);
                group.setPosition(position, true);
            }
        });


        group.setEnabled(false);

        Handler handler = new Handler();
        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                group.setEnabled(true);
            }
        };
        handler.postDelayed(runnable, 5000);
    }

    private void updateButton(int position) {
        button.setText("Position: " + position);
    }
}


edit: Also the example app looks like to be using different version of SegmentedButton, than whats in 1.2.2 edit: Tried version 1.1.1 and its working fine with the same code

TonyNikolov avatar May 22 '17 13:05 TonyNikolov

Hi TonyNikolov, I am planning to release version 2 of this library and there is lots of changes. Sample app you have downloaded uses this last version of the library. The problem you have faced could be already fixed or will be fixed in the next release. I cannot tell you when because I'm pretty busy these days, but I believe it won't last a month.

ceryle avatar May 23 '17 10:05 ceryle