Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TextView below ImageView

Tags:

android

I can't place the label where i want. I will show a picture.

enter image description here

I have the following code:

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    android:layout_weight="1"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textViewNombreVideo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/imageViewLogo"
        android:layout_alignParentBottom="true"
        android:layout_alignRight="@+id/imageViewLogo"
        android:lines="2"
        android:scrollHorizontally="false"
        android:singleLine="false"
        android:text="Medium Text"
        android:textAppearance="?android:attr/textAppearance"
        android:textColor="@android:color/white"
        android:textColorLink="@android:color/white"
        android:textStyle="bold" />

    <ImageView
        android:id="@+id/imageViewLogo"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@+id/textViewNombreVideo"
        android:layout_centerHorizontal="true"
        android:layout_margin="4dp"
        android:adjustViewBounds="true" />

</RelativeLayout>

The picture fit the heigh of the imageview, that's ok, and i want to place the textview with the same left of the picture.

Is it possible to do that?

like image 228
Jorge181 Avatar asked Sep 14 '25 04:09

Jorge181


1 Answers

Try this code.

<?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="match_parent"
    android:layout_gravity="center"
    android:layout_weight="1"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textViewNombreVideo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_alignLeft="@+id/imageViewLogo"
        android:layout_alignParentBottom="true"
        android:layout_alignRight="@+id/imageViewLogo"
        android:lines="2"
        android:scrollHorizontally="false"
        android:text="Medium Text"
        android:textAppearance="?android:attr/textAppearance"
        android:textColor="@android:color/black"
        android:textColorLink="@android:color/white"
        android:textStyle="bold"
        android:layout_marginBottom="10dp" />

    <ImageView
        android:id="@+id/imageViewLogo"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@+id/textViewNombreVideo"
        android:layout_centerHorizontal="true"
        android:layout_margin="4dp"
        android:src="@drawable/ic_launcher"
        android:adjustViewBounds="true"
     />

</RelativeLayout>

below UI design fron this code. as per your requirement.

enter image description here

like image 94
Mr.Sandy Avatar answered Sep 15 '25 16:09

Mr.Sandy