SegmentedButton icon indicating copy to clipboard operation
SegmentedButton copied to clipboard

how to add button dynamically ?

Open ismailtosun opened this issue 5 years ago • 2 comments

ismailtosun avatar Oct 12 '20 06:10 ismailtosun

public void AddSegments(int bookID, int chapterNum) {
        SegmentedButton yesButton = new SegmentedButton(this);
        yesButton.setText(bookListShortAbb[bookID - 1] + " " + chapterNum);
        yesButton.setPadding((int) dpToPx(5), (int) dpToPx(5), (int) dpToPx(5), (int) dpToPx(5));
        yesButton.setLayoutParams(new LinearLayout.LayoutParams(0, 60, 1));
        yesButton.setTextColor(Color.BLACK);
        yesButton.setTextSize(spToPx(20));
        segmentedButtonGroup.addView(yesButton);
    }
 private float dpToPx(float dp) {
        return dp * getResources().getDisplayMetrics().density;
    }

    private float pxToDp(float px) {
        return px / getResources().getDisplayMetrics().density;
    }

    private float spToPx(float sp) {
        return sp * getResources().getDisplayMetrics().scaledDensity;
    }

    private float pxToSp(float px) {
        return px / getResources().getDisplayMetrics().scaledDensity;
    }

bahaahany2019 avatar Oct 14 '20 19:10 bahaahany2019

Is this resolved for you?

addisonElliott avatar Jan 11 '21 13:01 addisonElliott