Reputation: 150779
As a learning exercise, I'm working on a very simple native Android widget.
The widget has a RelativeLayout containing a single ImageView and a single TextView. The TextView is populated with a name pulled from a web service while the ImageView is populated with a url from the same.
The TextView is positioned like this: android:layout_toRightOf="@+id/image"
My basic issue is trying to get the TextView sized to fit the content in it. I've only been able to figure out how to provide an explicit or inherited width in the TextView layout xml.
What I'd really like is something like this:
It doesn't appear possible to get a handle to the TextView inside the RemoteView the widget is using so I don't seem to be able to resize it on the fly.
Is there a recommended way to achieve the above layout?
Upvotes: 3
Views: 627
Reputation: 3332
Like 0gravity suggested, android:layout_width = "wrap_content". Then use paddings to adjust the space around your text until it looks as desired.
Upvotes: 1
Reputation: 1857
TextView
android:layout_width="wrap_content"
android:layout_alignParentRight="true"
ImageView
android:layout_toLeftOf="@+id/lTextView"
Upvotes: 1