0

I have a image view and text views in my layout and it looks like this

enter image description here

How can i fill the empty space with the text? i have used android:layout_toRightOf="@+id/movie_image" to get the text next to the image but it does not fill the empty space when the image is over.

My code

<RelativeLayout 
            android:id="@+id/upperPart"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            >

    <ImageView
            android:id="@+id/movie_image"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="left"
            android:layout_marginLeft="5dp"
            android:layout_marginTop="5dp"
            android:src="@drawable/ic_launcher"
            android:scaleType="fitXY"/>


    <TextView
        android:id="@+id/title_movie"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:layout_toRightOf="@+id/movie_image"
        android:text="@string/temp_title"
        android:textSize="18dp"
        android:textStyle="bold" />

     <TextView
        android:id="@+id/description_movie"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"
        android:layout_marginTop="5dp"
        android:text="@string/moviedescription"
        android:layout_toRightOf="@+id/movie_image"
        android:layout_below="@+id/title_movie"
        android:textSize="14dp"
         />


     </RelativeLayout>
CraZyDroiD
  • 6,622
  • 30
  • 95
  • 182

5 Answers5

1

Android's default TextView is not supported justificatoin.. and spanning with image view..

You need to check below example where you find what you needed for spanning image and text..

How to layout text to flow around an image

Community
  • 1
  • 1
0

The only best way is to make the edit text first and then keep the image view within it. And the other way is to set two edit text by which the empty spaces can be filled.

0

What you want is not possible yet in android. I'd suggest you to make textView scrollable instead.

Add following attributes in <TextView android:id="@+id/title_movie" .../>

android:maxLines = "9"
android:scrollbars = "vertical"
Apurva
  • 7,871
  • 7
  • 40
  • 59
0

To Achieve this, you can use two Text views one which is to the rightOf your ImageView and has the text till the Bottom of Image View. Another text view which will be below the Image view and has a width of match_parent. This will not leave any space. Hope this may help you.

keshav kowshik
  • 2,354
  • 4
  • 22
  • 45
0

Try this,

<RelativeLayout
        android:id="@+id/upperPart"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <LinearLayout
            android:id="@+id/lin_image"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:gravity="center"
            android:orientation="vertical" >

            <ImageView
                android:id="@+id/movie_image"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_gravity="left"
                android:layout_marginLeft="5dp"
                android:layout_marginTop="5dp"
                android:background="@drawable/ic_launcher" />
        </LinearLayout>

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_toRightOf="@+id/lin_image" >

            <TextView
                android:id="@+id/title_movie"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="5dp"
                android:layout_marginRight="5dp"
                android:text="@string/temp_title"
                android:textSize="18dp"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/description_movie"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/title_movie"
                android:layout_marginLeft="5dp"
                android:layout_marginTop="5dp"
                android:text="@string/moviedescription"
                android:textSize="14dp" />
        </RelativeLayout>
    </RelativeLayout>
Jignesh Jain
  • 1,518
  • 12
  • 28