Monday, April 2, 2012

Re: [android-developers] Re: Textview gravity resets

If your text view is set to wrap_content, its width will match the text it contains, and so, by definition, changing android:gravity will have no effect (this is true for single-line text, but let's keep things simple for the sake of discussion).

What you want is one of:

android:layout_width="fill_parent"
android:gravity="right"

or

android:layout_width="wrap_content"
android:layout_gravity="right"

Note the use of layout_gravity in the second case, pushing the view itself to the right. That's for a vertical linear layout - for relative layout, use android:layout_alignParentRight="true".

-- K

2 апреля 2012 г. 16:24 пользователь adev <enricong@gmail.com> написал:
It is set to wrap_content, I have tried match_parent and fill_parent
but there is no difference.

After the adview loads, everything APPEARS Left.
However, if I programmatically look at the gravity attribute of the
textview, the gravity is still set to right|center_vertical

On Apr 2, 5:04 am, Kostya Vasilyev <kmans...@gmail.com> wrote:
> There is - layout_width="wrap_content" on the text view.
>
> 2 апреля 2012 г. 7:30 пользователь adev <enric...@gmail.com> написал:
>
>
>
>
>
>
>
> > I've tried dynamically changing each text view, but nothing happens
> > when I change it.
> > Is there anything thing else that would cause a text view to APPEAR to
> > be left justified eventhough gravity is still set to RIGHT?
>
> > On Apr 1, 9:54 am, adev <enric...@gmail.com> wrote:
> > > The adview and admob is all in the XML.
> > > I do not have any code related to it.
> > > So that is not dynamic.
> > > However, it seems that the height of the adview is not determined
> > > until the ad is loaded.
> > > When I start the app, the adview height seems to be zero, then after
> > > one or two seconds, it appears and the rest of the layout resizes to
> > > fit.
> > > This is when the gravity is reset.
> > > I couldn't figure out how to have a preset height.
>
> > > On Apr 1, 1:52 am, Narendra Singh Rathore <nsr.curi...@gmail.com>
> > > wrote:
>
> > > > On Sun, Apr 1, 2012 at 8:01 AM, adev <enric...@gmail.com> wrote:
> > > > > Sure I can reset the gravity on all of them in code, but that defeats
> > > > > the purpose of using the XML.
>
> > > > No, not at all. Just reset the gravity of only the TextView in code.
> > You
> > > > need not to reset the gravity of all of them, as you are facing the
> > problem
> > > > only because of TextView's gravity.
>
> > > > > I'd like to know the cause of the issue I'm seeing now and solve it.
>
> > > > The cause of issue might be that, your adview is being loaded
> > dynamically,
> > > > hence you have to resolve the matter dynamically through code.
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.> To post to this group, send email toandroid-developers@googlegroups.com
> > To unsubscribe from this group, send email to>android-developers+unsubscribe@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment