I am searching for a way to position my text around my imageview (so like the css float left/right).
How can I do this in Android? I have used android:layout_alignParentLeft="true"
(to position my imageview left) and android:layout_alignParentRight="true"
for my textview but the
textview comes next to the imageView and doesn't continue underneath the ImageView when I have a long text..
Any ideas?
I had the same problem trying to get a ImageView aligned to the left of a RelativeLayout. I used android:scaleType="fitStart" to get it fixed.
My XML-file:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:padding="10dp">
<ImageView
android:layout_height="50dp"
android:id="@+id/country_icon"
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:scaleType="fitStart" />
</RelativeLayout>
I've also tried many ways but no luck. I don't think Text would flow in the current Android as it does in html.
There is no easy way to get this done. You can either use 2 text views, one next to the imageview and one below the imageview. And if you are lucky in getting a constant sized image around which you need to wrap the text (i was), calculate the number of characters that would fit in the textview next to the image and break your string in two parts. Just make sure that you don't split the text in the middle of a word.
I had also tried using html, but for that i had to use a webview, it was heavy and dirty. Preferred the splitting text version.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With