0

enter image description here

enter image description here First of all ; I can not tell my problem. Because My english degree is not enough for telling these. So check my images to understand me. By the way , sorry about that.

I want to set ImageView between 2 different layouts.You can see, There isn't any ImageView in first one. Second one There is a red box ( ImageView ). How can I write it to my layout ?

Here is my layout code.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
   android:orientation="vertical"
    android:layout_height="match_parent"
    >
<LinearLayout
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:layout_height="160dp"
   android:background="@drawable/porfoy_resmi777" >



    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginTop="15dp"
        android:paddingLeft="20dp"

        >
        <TextView
            android:textStyle="bold"
            android:textColor="#FFFFFF"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Gönderi:"
            android:layout_marginLeft="60dp"

            />
        <TextView
            android:textStyle="bold"
            android:textColor="#FFFFFF"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Takip edilen"
            android:layout_marginLeft="20dp"
            />
        <TextView
            android:textStyle="bold"
            android:textColor="#FFFFFF"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Takipçi"
            android:layout_marginLeft="20dp"
            />



    </LinearLayout>


    <LinearLayout
        android:layout_marginTop="8dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="75dp"
        android:paddingLeft="25dp"
        >
        <TextView
            android:textStyle="bold"
            android:textColor="#FFFFFF"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="0"/>
        <TextView
            android:textStyle="bold"
            android:textColor="#FFFFFF"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="0"
            android:layout_marginLeft="87dp"/>

        <TextView
            android:textColor="#FFFFFF"
            android:textStyle="bold"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="0"
            android:layout_marginLeft="70dp" />





    </LinearLayout>









</LinearLayout>





    <LinearLayout
        android:layout_width="match_parent"
        android:orientation="horizontal"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:layout_marginLeft="60dp">




        <ImageView
            android:layout_marginLeft="50dp"
            android:id="@+id/telefon_arama_ImageView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
android:background="@drawable/cla"
            />

        <TextView
            android:id="@+id/telefon_numarasi"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="5"
            android:text="numaram"
            android:layout_marginLeft="20dp"
            android:textStyle="bold"/>
    </LinearLayout>

 <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="37dp"
    android:orientation="horizontal"
    android:background="@drawable/radyan"
    >

    <ImageView
        android:id="@+id/btn_group"
        style="@style/Widget.AppCompat.Button.Borderless"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:src="@drawable/kedi"
        />

    <ImageView
        android:id="@+id/btn_sing"
        style="@style/Widget.AppCompat.Button.Borderless"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/bulok"
        />

    <Button
        android:id="@+id/profil_btn_duzenle"
        style="@style/Widget.AppCompat.Button.Borderless"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:gravity="center"
        android:text="Düzenle"
        android:textAllCaps="false"
        android:textSize="11sp" />


    <Button
        android:id="@+id/profil_cikis"
        style="@style/Widget.AppCompat.Button.Borderless"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:gravity="center"
        android:text="Çıkış"

        android:textAllCaps="false"
        android:textSize="13sp" />

</LinearLayout>


<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">


        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Hakkımda :"
            android:textStyle="bold"
            android:textSize="11dp"/>

        <TextView
            android:id="@+id/Hakkında_bakıs_TextView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="14dp"
            android:text="bafbafgfdafadfad"
            android:textStyle="italic|bold"
            />


    </LinearLayout>
</ScrollView>

2 Answers2

1

As you have shown in your screenshot, you want to overlap imageview by putting another imageview, that can be done using Relative Layout.

i changed your root layout to "RelativeLayout". check xml you will understand what i have done, it's pretty easy. If you have any problem let me know i will write detailed explanation.

you can learn more about android user interface design layouts here https://www.youtube.com/watch?v=OQ5ao6PGCAs

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <LinearLayout
        android:id="@+id/linearlayout_banner"
        android:layout_width="match_parent"
        android:layout_height="160dp"
        android:background="@drawable/porfoy_resmi777"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="15dp"
            android:orientation="horizontal"
            android:paddingLeft="20dp">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="60dp"
                android:text="Gönderi:"
                android:textColor="#FFFFFF"
                android:textStyle="bold" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="20dp"
                android:text="Takip edilen"
                android:textColor="#FFFFFF"
                android:textStyle="bold" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="20dp"
                android:text="Takipçi"
                android:textColor="#FFFFFF"
                android:textStyle="bold" />


        </LinearLayout>


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="75dp"
            android:layout_marginTop="8dp"
            android:paddingLeft="25dp">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="0"
                android:textColor="#FFFFFF"
                android:textStyle="bold" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="87dp"
                android:text="0"
                android:textColor="#FFFFFF"
                android:textStyle="bold" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="70dp"
                android:text="0"
                android:textColor="#FFFFFF"
                android:textStyle="bold" />


        </LinearLayout>


    </LinearLayout>


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/linearlayout_banner"
        android:layout_marginLeft="16dp"
        android:layout_marginTop="-40dp"
        android:orientation="horizontal">

        <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">

            <ImageView
                android:id="@+id/telefon_arama_ImageView"
                android:layout_width="120dp"
                android:layout_height="120dp"
                android:layout_weight="1"
                android:background="@drawable/cla" />
        </RelativeLayout>

        <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="50dp">

            <TextView
                android:id="@+id/telefon_numarasi"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="20dp"
                android:layout_weight="5"
                android:text="numaram"
                android:textStyle="bold" />
        </RelativeLayout>
    </LinearLayout>

</RelativeLayout>

enter image description here

Amir Dora.
  • 2,831
  • 4
  • 40
  • 61
  • First of all ; I made a mistake. I forget to add tabs(There is android:background="@drawable/radyan" in LinearLayout ) and scrollview area. Could you please edit your answer according to new my edited question. By the way : Yes. I do not understand what have done. How can move LinearLayout in RelativeLayout. – Hatay Berkay Işıkoğlu May 10 '18 at 19:43
  • I did it. Thanks your answer. But I still do not understand how it works. – Hatay Berkay Işıkoğlu May 10 '18 at 19:58
0

You should be using a RelativeLayout instead of a LinearLayout for this. A LinearLayout uses an eldest child first along the X (horizontal orientation) or Y (vertical orientation). RelativeLayout orders children along the Z axis (ie, places children on top of each other). Since you need to overlay an image, you need to use RelativeLayout. The easiest way would be to place the image in code. A quick Google search should give you several examples. To give you an idea, you need to replace the root LinerLayout with a RelativeLayout.

// Then get reference to this in code
RelativeLayout rl = (RelativeLayout) findViewById(R.id.my_relative_layout);

// Then you can place your image wherever you want
// You will have to provide the dp values of the coordinates
ImageView iv = new ImageView(this);
iv.setBackgroundColor(Color.RED);
params = new RelativeLayout.LayoutParams(30, 40);
params.leftMargin = 50;
params.topMargin = 60;
rl.addView(iv, params);

The following stackoverflow answer has more details on this: Set the absolute position of a view

ucsunil
  • 7,378
  • 1
  • 27
  • 32