Override views in android?

I have a linearlayout that has a text box (multi-line, almost 5 lines) and an image. Is it possible to draw an image in text form (overlap)?

Note. I have to indicate the coordinates of the image, which are not static, and can be anywhere above the text.

Something like this layout:

enter image description here

+3
source share
4 answers

I think this can be achieved using RelativeLayout.

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <TextView
                android:id="@+id/Textview"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="20dp"
                android:text="@string/Text2display"
                android:textColor="#EEDCAA" />


        <ImageView
            android:id="@+id/choose_img"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="-46dp"
            android:adjustViewBounds="true"
            android:contentDescription="@string/description_logo"
            android:src="@drawable/user2" />

    </RelativeLayout>

By placing the TextView block over the ImageView, it ensures that the image overlaps the TextView. Now, based on your requirements and situation, use the following links from the link: -

http://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams.html

, . ImageView, . . , ,

- ?

+1

, RelativeLayout. TextView TextView, LinearLayout.

0

() LinearLayout, TextView onDraw, .

0

all your xml files, , :

Add this android:background="@android:color/black"to the view tag that you defined.

0
source

Source: https://habr.com/ru/post/1794687/


All Articles