Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImageView and TextView float (left/right) Android

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?

like image 754
wouter88 Avatar asked Dec 21 '09 11:12

wouter88


3 Answers

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>
like image 76
ScratchMyTail Avatar answered Nov 17 '22 21:11

ScratchMyTail


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.

like image 26
hwii77 Avatar answered Nov 17 '22 21:11

hwii77


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.

like image 1
Shubhayu Avatar answered Nov 17 '22 23:11

Shubhayu