Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scrolling? #20

Open
dhiraj opened this issue Jan 20, 2016 · 9 comments
Open

Scrolling? #20

dhiraj opened this issue Jan 20, 2016 · 9 comments

Comments

@dhiraj
Copy link

dhiraj commented Jan 20, 2016

In iOS, when we have too many items in the Action Sheet, more than can be displayed on screen, it automatically starts scrolling.

Is there any chance of scrolling being implemented in the action sheet? Please at least give suggestions on how this could be done, and I'll try to implement it.

@RishavChudal
Copy link

Did you get any idea on scrolling the actionsheet?

@ZdzCoding
Copy link

you can add a ScrollView

@RishavChudal
Copy link

have you added code or something that will help to add a scroll view?

On Tue, Aug 30, 2016 at 3:42 PM, zhaodaizheng [email protected]
wrote:

you can add a ScrollView


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#20 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AM-JvXBlmqyTpcMEjQYmStxm9bdJUBQXks5qk_52gaJpZM4HIVzk
.

@afiqiqmal
Copy link

OK i solved it by change your code a little bit.. i add a scrollview and the cancel button stay at the bottom.. can you take a look at this code.. and add to your library, so everyone can use it. TQ

private void createItems() {
        String[] titles = getOtherButtonTitles();

        RelativeLayout relativeLayout = new RelativeLayout(getActivity());
        RelativeLayout.LayoutParams rll = new RelativeLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
        relativeLayout.setLayoutParams(rll);

        ScrollView scrollView = new ScrollView(getActivity());
        RelativeLayout.LayoutParams ll = new RelativeLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
        ll.addRule(RelativeLayout.ABOVE,ActionSheet.CANCEL_BUTTON_ID);
        ll.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
        scrollView.setLayoutParams(ll);
        scrollView.setPadding(0,0,0,200);

        LinearLayout linearLayout = new LinearLayout(getActivity());
        LinearLayout.LayoutParams ll2 = new LinearLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
        linearLayout.setOrientation(LinearLayout.VERTICAL);
        linearLayout.setLayoutParams(ll2);

        if (titles != null) {
            for (int i = 0; i < titles.length; i++) {
                Button bt = new Button(getActivity());
                bt.setId(CANCEL_BUTTON_ID + i + 1);
                bt.setOnClickListener(this);
                bt.setBackgroundDrawable(getOtherButtonBg(titles, i));
                bt.setText(titles[i]);
                bt.setTextColor(mAttrs.otherButtonTextColor);
                bt.setTextSize(TypedValue.COMPLEX_UNIT_PX, mAttrs.actionSheetTextSize);
                if (i > 0) {
                    LinearLayout.LayoutParams params = createButtonLayoutParams();
                    params.topMargin = mAttrs.otherButtonSpacing;
                    linearLayout.addView(bt, params);
                } else {
                    linearLayout.addView(bt);
                }
            }
        }

        scrollView.addView(linearLayout);
        relativeLayout.addView(scrollView);

        Button bt = new Button(getActivity());
        bt.getPaint().setFakeBoldText(true);
        bt.setTextSize(TypedValue.COMPLEX_UNIT_PX, mAttrs.actionSheetTextSize);
        bt.setId(ActionSheet.CANCEL_BUTTON_ID);
        bt.setBackgroundDrawable(mAttrs.cancelButtonBackground);
        bt.setText(getCancelButtonTitle());
        bt.setTextColor(mAttrs.cancelButtonTextColor);
        bt.setOnClickListener(this);
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
        params.topMargin = mAttrs.cancelButtonMarginTop;
        params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
        bt.setLayoutParams(params);

        relativeLayout.addView(bt);

        mPanel.addView(relativeLayout);

        mPanel.setBackgroundDrawable(mAttrs.background);
        mPanel.setPadding(mAttrs.padding, mAttrs.padding, mAttrs.padding, mAttrs.padding);
    }

@RishavChudal
Copy link

Thankyou very much #afiq for your help.

@afiqiqmal
Copy link

i just create new class ActionSheet.java..and copy all the code from the library and replace it with this code.. :)

@RishavChudal
Copy link

Do i have to replace all the code from actionsheet java?

On Mon, Sep 12, 2016 at 10:39 PM, Hafiq Iqmal [email protected]
wrote:

i just create new class ActionSheet.java..and copy all the code from the
library and replace it with this code.. :)


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#20 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AM-JvSRnOqp3BeK5toqZxJUHk2_9gDCVks5qpYOsgaJpZM4HIVzk
.

@RishavChudal
Copy link

Oh sorry, i got u wrong. First i have to create a new class and use the above code that you gave. Is it?

@afiqiqmal
Copy link

Yup..

On 13 Sep 2016 01:10, "Rishav Chudal" [email protected] wrote:

Oh sorry, i got u wrong. First i have to create a new class and use the
above code that you gave. Is it?


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#20 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AIocsBlkrfDMOAcPeQ-XDs-B1Ws_8SJpks5qpYePgaJpZM4HIVzk
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants