how to set a text over an imageView?

后端 未结 8 552
日久生厌
日久生厌 2020-12-05 07:20

I am placing an application bar on the top of the screen and it looks as the following figure:

\"enter

相关标签:
8条回答
  • 2020-12-05 08:02

    That's how I did it and it worked exactly as you asked for:

    <ImageView
        android:id="@+id/myImageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/myImageSouce" />
    
    <TextView
        android:id="@+id/myImageViewText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/myImageView"
        android:layout_alignTop="@+id/myImageView"
        android:layout_alignRight="@+id/myImageView"
        android:layout_alignBottom="@+id/myImageView"
        android:layout_margin="1dp"
        android:gravity="center"
        android:text="Hello"
        android:textColor="#000000" />
    

    Use Relative layout for this

    0 讨论(0)
  • 2020-12-05 08:06

    If i guessed correctly you are trying to use Header for you sample..

    Set Background as that image and Add text view to that like this..

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_height="55px"
        android:background="@drawable/testheader"
        android:layout_width="fill_parent"
        android:orientation="horizontal">           
            <TextView android:id="@+id/quaddeal_header_text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="12dip"
                android:text="Campus"
                android:textSize="20sp"
                android:textColor="@color/white"
                android:layout_marginLeft="90dip"/>
    </RelativeLayout>
    

    Or else You have to merge the Layouts by using Framelayout.

    Check this Sample for Frame Layout

    0 讨论(0)
提交回复
热议问题