-2

I've started today with Android programming, so, as a beginner, i'm curious is there any better and more appropriate way to make this layout than i've made with my XML code. I need to have two containers that hold some picture and text that stands below that picture (see image below), each.

layout

XML:

<LinearLayout 
   android:layout_width="fill_parent"
   android:layout_height="140dp"
   android:orientation="horizontal"
   android:baselineAligned="false"
   >

 <RelativeLayout 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1">
 <RelativeLayout 
    android:layout_centerInParent="true"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:paddingBottom="10dp"
    android:paddingLeft="10dp"
    android:paddingRight="10dp"
    android:background="#024f50"> 

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_marginBottom="60dp"
        android:src="@drawable/doktor"
        android:contentDescription="@string/doktor"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:text="@string/doktor"
        android:layout_alignParentBottom="true" 
        android:textColor="@color/box_text"/>

    <View
        android:layout_width="0dp"
        android:layout_height="60dp"
        android:layout_alignParentBottom="true" />
 </RelativeLayout>
 </RelativeLayout>

 <RelativeLayout 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1">
 <RelativeLayout 
    android:layout_centerInParent="true"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:paddingBottom="10dp"
    android:paddingLeft="10dp"
    android:paddingRight="10dp"
    android:background="#024f50"> 

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_marginBottom="60dp"
        android:src="@drawable/sestra"
        android:contentDescription="@string/sestra"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:text="@string/sestra"
        android:layout_alignParentBottom="true" 
        android:textColor="@color/box_text"/>

    <View
        android:layout_width="0dp"
        android:layout_height="60dp"
        android:layout_alignParentBottom="true" />
  </RelativeLayout>
  </RelativeLayout>

</LinearLayout>
Ljubisa Livac
  • 819
  • 3
  • 13
  • 38

1 Answers1

2

Use

android:drawableTop=""

in TextView for adding image.

        <TextView
            android:drawableTop="@drawable/your_drawable"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:text="@string/doktor"
            android:layout_alignParentBottom="true"
            android:textColor="@color/box_text"/>
Slampy
  • 326
  • 1
  • 7