Change rlp to

                RelativeLayout.LayoutParams rlp = new 
RelativeLayout.LayoutParams(
                                LayoutParams.WRAP_CONTENT, 
LayoutParams.WRAP_CONTENT);

Because what your original code did was to make the TextView fill up
the width of the screen.

On Apr 11, 8:23 am, Android-Berry <[EMAIL PROTECTED]> wrote:
> Hi There,
>
> I have created RelativeLayout and added only one TextView to make
> display at the center-horizantal.
>
> However, it does not work. it always show up left-align.
>
> Here is my code:
>
>      RelativeLayout rl = new RelativeLayout(this);
>      rl.setLayoutParams(new RelativeLayout.LayoutParams(
>      LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
>      TextView view = new TextView(this);
>             view.setHeight(40);
>       view.setText("Test");
>       RelativeLayout.LayoutParams rlp =  new
> RelativeLayout.LayoutParams(
>                 LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
>      rlp.addRule(RelativeLayout.CENTER_HORIZONTAL);
>      rl.addView(view,rlp);
>      setContentView(rl);
>
> Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to