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

Center of ScalableLayout #18

Closed
lapngodoan opened this issue Nov 29, 2014 · 6 comments
Closed

Center of ScalableLayout #18

lapngodoan opened this issue Nov 29, 2014 · 6 comments

Comments

@lapngodoan
Copy link

Hi Ssomai,
Thank for your library.
I have a question. In the ScalableLayout, how can we put a view in the center of this layout?
For example, in the scalable layout, I have 3 view: PreviousButton ---- TextView -----NextButton
The content of textview is changed dynamically. How to ensure this text is alway the center of the layout?
(Like RelaytiveLayout)
Thank

@ssomai
Copy link
Owner

ssomai commented Nov 29, 2014

Hello, thank you for your issue and interest in my work.
Above, I beg your pardon for my english.

I suppose what you want that textview is in wrap content but dont move both buttons. is it right?
I'll add another field for that feature, then I'll re-comment.
If I am wrong, please re-comment to me.

Thank you for the issue.

@ssomai
Copy link
Owner

ssomai commented Nov 30, 2014

Hello.
I added the feature that I suppose.
I added parameter 'pMoveSiblings' at method 'setTextView_WrapContent' of class 'ScalableLayout'
and attached sample code what you want, I suppose.
I hope these help.

LinearLayout ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
setContentView(ll);

mSL = new ScalableLayout(this, 2000, 500);
mSL.setBackgroundColor(Color.LTGRAY);
ScalableLayout.setLoggable();
ll.addView(mSL, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);

Button btn_prev = new Button(this);
btn_prev.setText("Prev");
mSL.addView(btn_prev, 0, 0, 200, 500);

final TextView tv = new TextView(this);
tv.setText("TextView");
tv.setBackgroundColor(Color.RED);
mSL.addView(tv, 1000, 0, 1, 500);
mSL.setTextView_WrapContent(tv, TextView_WrapContent_Direction.Center_Horizontal, false, false);

Button btn_next = new Button(this);
btn_next.setText("Next");
mSL.addView(btn_next, 1800, 0, 200, 500);

Button btn_small = new Button(this);
btn_small.setText("Small");
btn_small.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        tv.setText(tv.getText().toString().substring(0, tv.getText().length()/2));
    }
});
ll.addView(btn_small, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);

Button btn_large = new Button(this);
btn_large.setText("large");
btn_large.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        tv.setText(tv.getText()+"testtest");
    }
});
ll.addView(btn_large, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);

@lapngodoan
Copy link
Author

Hi Youngmann Kim,
This new update is what I really want.It helps me resolve my issues a lot.
But I think, it'd better if we have TextView_WrapContent_Direction.Center_Vertical and TextView_WrapContent_Direction.Center (for both direction).
How do you think about this?
Anyway, thank for your great news!

@ssomai
Copy link
Owner

ssomai commented Dec 1, 2014

Yeah, you're right.
I'll do it as soon as, then re-comment here.

Thanks. :)

@ssomai ssomai reopened this Dec 1, 2014
@ssomai
Copy link
Owner

ssomai commented Dec 1, 2014

Uhm...

TextView_WrapContent_Direction.Center_Vertical will be implemented easily.

But TextView_WrapContent_Direction.Center makes me confused....
Let me think about it.

Thanks :)

@ssomai
Copy link
Owner

ssomai commented Jul 29, 2015

I'm sorry for late update.

I Implemented TextView_WrapContent_Direction.Center_Vertical.
But I can't make TextView_WrapContent_Direction.Center, because I can't decide which direction is right to expand.

Thanks. :)

@ssomai ssomai closed this as completed Jul 29, 2015
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

2 participants