Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make layout of an image and text left and under it?

I need to make a layout which is specific to webpage and it needs to look like a web article with an image and a text left to and under it. Look at the image.

As this is an easy thing to do in a web world, I am not sure how to do it in XML layout.

Obviously, the TextView must be on the left while the image is present, and after it reaches the bottom of the image, it has to stretch to the screen width. I tried this with two TextViews (one for left and another for bottom), but it just does not look right due to the text font size.


EDIT

I also tried to dinamically catch the height of image and then assign it to my TextView, and then make another TextView with the size of the screen under these two elements. This does not work as well as I cannot control the text that is not visible due to limited height of the first TextView.

like image 947
sandalone Avatar asked Nov 14 '22 07:11

sandalone


1 Answers

If you haven't found the answer yet. Here is the same kind of question that is being answered.

How to align TextView around an ImageView?

The only thing what you might have to change in your case is to, make the alignment to be opposite way.

<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp">
<TextView
    android:textSize="18.0sp"
    android:id="@+id/message_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="@string/text" />
<ImageView 
    android:src="@drawable/icon"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@+id/message_view"
    android:id="@+id/icon" />

Taken from here,

http://dev.androidteam.ru/snippets/textview/leadingmarginspan2

like image 185
Andro Selva Avatar answered Nov 16 '22 04:11

Andro Selva