You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Android两个不同布局之间放置ImageView

解决方案

没问题!根据你的需求,我会帮你在顶部的背景布局(包含Gönderi、Takip edilen等文本的区域)和下方的电话栏布局之间添加你需要的ImageView。以下是修改后的完整布局代码:

<?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>

    <!-- 新增的目标ImageView,可根据需求调整属性 -->
    <ImageView
        android:id="@+id/target_profile_image"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_marginTop="-50dp"
        android:layout_marginBottom="16dp"
        android:src="@drawable/your_image_resource"
        android:layout_gravity="center_horizontal"
        android:background="@drawable/circle_background" />

    <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"/>
            <!-- 记得补全你原始代码中截断的剩余布局内容 -->
        </LinearLayout>
    </ScrollView>
</LinearLayout>

关键修改说明

  • 我在顶部背景布局和电话栏布局之间插入了目标ImageView,设置了负的layout_marginTop让它可以叠加在顶部背景的下方,模拟常见的头像布局效果,你可以根据实际设计调整这个值。
  • 替换android:src="@drawable/your_image_resource"为你实际的图片资源ID,如果需要圆形头像,可以添加一个圆形背景的drawable给android:background。
  • 你还可以自由调整这个ImageView的大小、间距、对齐方式等属性,完全匹配你的设计需求。

内容的提问来源于stack exchange,提问作者Hatay Berkay Işıkoğlu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 07:13:14