K
K
Konstantin Kanaev2014-06-10 10:28:01
Android
Konstantin Kanaev, 2014-06-10 10:28:01

Positioning elements relative to each other in android

Hello. I've been struggling for an hour with placing an inscription (TextView) under the picture (ImageView). As far as I understand, there is a layout_below for this, but for some reason it does not work. Please help.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    tools:context="ru.lalala.olalala.MainActivity$PlaceholderFragment" >

    <ImageView
        android:id="@+id/imageViewPhotoReclame"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:scaleType="fitStart"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:contentDescription="@string/photo_reclame"
        android:src="@drawable/restourant_main" />

    <TextView
        android:id="@+id/textViewReclameNews"
        android:text="@string/main_text_reclame"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
    android:layout_below="@id/imageViewPhotoReclame"/>

</RelativeLayout>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mintormo, 2014-06-10
@Yoh_Asakura

Remove the orientation attribute from the RelativeLayout: it's for the LinearLayout. In the ImageView, specify that it is above the TextView.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question