0

i want to achieve this image 1

but i got this image 2

here is my layout

        <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@android:color/black">
        <ImageView
            android:id="@+id/imf"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/frame001"
            />

        <TextView
            android:id="@+id/firetext"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="170dp"
            android:text="Android"
            android:textStyle="bold"
            android:textColor="@android:color/white" />


    </RelativeLayout>

is there any way to scale the imageview width to scale the textview width considering that the text in the textview is dynamic

Zack Khenniba
  • 53
  • 2
  • 7
  • I haven't time to write code now but you can take text width size and set image width according text width... see this: http://stackoverflow.com/questions/21926644/get-height-and-width-of-a-layout-programatically – AsfK Nov 10 '15 at 16:53
  • Use leftOf and RightOf rules of relativeLayout. Also consider this: http://stackoverflow.com/questions/29956014/why-should-we-use-xml-layouts – Nanoc Nov 10 '15 at 17:00
  • 1
    Simply use a **compound drawable** into yor TextView (and get rid of the ImageView): better performances, flatter design, very easy to implement. `android:drawableTop="@drawable/frame001"` – Phantômaxx Nov 10 '15 at 17:03

2 Answers2

0

I think this will work, but I did not try it.

<LinearLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="vertical"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@android:color/black"
            android:orientation="vertical">
            <ImageView
                android:id="@+id/imf"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:src="@drawable/frame001"
                />

            <TextView
                android:id="@+id/firetext"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="170dp"
                android:text="Android"
                android:textStyle="bold"
                android:textColor="@android:color/white" />


        </LinearLayout>
Omid Aminiva
  • 667
  • 5
  • 14
0
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@android:color/black">
    <ImageView
        android:id="@+id/imf"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/frame001"
        android:layout_alignLeft="@+id/firetext"
        android:layout_alignRight="@+id/firetext" />

    <TextView
        android:id="@+id/firetext"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="170dp"
        android:text="Android"
        android:textStyle="bold"
        android:textColor="@android:color/white" />