مرجع تخصصی برنامه نویسان

انجمن تخصصی برنامه نویسان فارسی زبان

کاربر سایت

pourya.montakhab

عضویت از 1397/07/14

مشکل با RelativeLayout

  • چهارشنبه 11 اردیبهشت 1398
  • 19:20
تشکر میکنم

سلام دوستان . 

من یک اکتیویتی ساختم به نام ProfileActivity   و حالا درون فایل لایوت اکتیویتی به صورت text  دارم کد های ویوم رو میزنم . 

نسخه اندرویدم 3.4 هست و بجای RelativeLayout از ConstraintLayout  استفاده شده (به طور پیشفرض خود اندروید استودیو جایگزین کرده در این نسخه )

این کدهام هستش : 

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/colorPrimary"
    tools:context=".profileActivity">

    <ImageView
        android:id="@+id/form_background_image"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:src="@drawable/form_background"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
    <RelativeLayout
        android:id="@+id/const1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@+id/form_background_image">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:layout_marginTop="@dimen/standard_margin"
            android:layout_marginRight="@dimen/standard_margin"
            android:text="اطلاعات کاربری"
            android:textColor="@color/white"
            android:textSize="@dimen/font_size_normal" />

        <ImageButton
            android:layout_width="@dimen/action_button_size"
            android:layout_height="@dimen/action_button_size"
            android:layout_centerVertical="true"
            android:layout_marginLeft="@dimen/standard_margin"
            android:layout_marginTop="@dimen/standard_margin"
            android:background="@null"
            android:src="@drawable/back_icon_white" />


        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="تغییر عکس"
            android:layout_alignRight="@id/form_background_image"/>
        <ImageView
            android:layout_width="62dp"
            android:layout_height="62dp"
            android:src="@drawable/defualt_avatar"
            android:layout_alignRight="@id/form_background_image"
            />
    </RelativeLayout>

</android.support.constraint.ConstraintLayout>

این imageView  و button  اخری رو میخوام با توجه به اون imageView اولی که خارج از RelativeLayout هست و بک گراندم هست جاگذاری کنم .

اما خطایی که بهم میده این هست :

@id/form_background_image is not a sibling in the same RelativeLayout l

ممنون

پاسخ های این پرسش

تعداد پاسخ ها : 2 پاسخ
کاربر سایت

نرجس اسماعیلی

عضویت از 1393/01/20

  • چهارشنبه 25 اردیبهشت 1398
  • 15:55

شما چرا دو بار id/form_background_image اینو توی کدتون تکرار کردید؟

برای باتن تون دو بار id نوشتید یه بار کدتونو با دقت ببینید

کاربر سایت

vslearn

عضویت از 1395/11/05

  • یکشنبه 29 اردیبهشت 1398
  • 14:18

شما برای هر یک از ابجکت ها باید id بدی و شما نمی تونی به layout یک ابجکت id بدی

کاربرانی که از این پست تشکر کرده اند

هیچ کاربری تا کنون از این پست تشکر نکرده است

اگر نیاز به یک مشاور در زمینه طراحی سایت ، برنامه نویسی و بازاریابی الکترونیکی دارید

با ما تماس بگیرید تا در این مسیر همراهتان باشیم :)