Christopher Littlewood
Christopher Littlewood

Reputation: 803

Error 350 with layout_height (Android Studio)

I am getting this error when i try to build my application:

error: '350' is incompatible with attribute android:layout_height (attr) dimension|enum [fill_parent=4294967295, match_parent=4294967295, wrap_content=4294967294].
Message{kind=ERROR, text=error: '350' is incompatible with attribute android:layout_height (attr) dimension|enum [fill_parent=4294967295, match_parent=4294967295, wrap_content=4294967294]., sources=[C:\Users\chris\Documents\GitHub\IFB398\MiBaseApplication\app\src\main\res\layout\activity_login_screen.xml:30], original message=, tool name=Optional.of(AAPT)}

I am using Android studio and I am really new to all this.

EDIT 1:

<EditText
        android:id="@+id/UsernameEditText"
        android:layout_width="307dp"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:ems="10"
        android:hint="Username"
        android:inputType="textPersonName"
        android:textColor="@android:color/background_light"
        android:textColorHint="@android:color/darker_gray"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.513"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.55" />

    <ImageView
        android:id="@+id/LogoImageView"
        android:layout_width="350"
        android:layout_height="350"
        android:layout_marginBottom="6dp"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.0"
        app:srcCompat="@mipmap/mibaselogo" />

    <EditText
        android:id="@+id/PasswordEditText"
        android:layout_width="309dp"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:ems="10"
        android:hint="Password"
        android:inputType="textPassword"
        android:textColor="@android:color/background_light"
        android:textColorHint="@android:color/darker_gray"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.514"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/UsernameEditText"
        app:layout_constraintVertical_bias="0.085" />

I have not added all code. Just the section above and below the error. (I am assuming that the error was on line 30 which is the start of the image.

Upvotes: 1

Views: 6877

Answers (5)

Blarzek
Blarzek

Reputation: 157

What if I want to specify a percentage? I receive the following message:

error APT2259: '50%' is incompatible with attribute height (attr) dimension.

Upvotes: 1

Dinesh Kumar Yadav
Dinesh Kumar Yadav

Reputation: 71

Must use specific dimensions like dip or dp.Update code:

 <ImageView
    android:id="@+id/LogoImageView"
    android:layout_width="350dp"
    android:layout_height="350dp"
    android:layout_marginBottom="6dp"
    android:layout_marginEnd="8dp"
    android:layout_marginStart="8dp"
    android:layout_marginTop="8dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.0"
    app:srcCompat="@mipmap/mibaselogo" />

Upvotes: 1

Android Geek
Android Geek

Reputation: 9225

Check your xml code

   <RelativeLayout
        android:layout_width="match_parent"
        android:background="@drawable/button_selector"
        android:layout_marginRight="10dp"
        android:layout_marginTop="10dp"
        android:layout_marginLeft="10dp"
        android:layout_height="40dp">

        <Button
            android:id="@+id/button_select"
            android:layout_width="wrap_content"
            android:layout_height="30dp"
            android:text="Select"
            android:background="#d57200"
            android:layout_centerInParent="true"
            android:textSize="18dp"
            android:textColor="#fff"
            android:textAllCaps="false"/>

    </RelativeLayout>

I think you not give the valid height and width, please check your xml code

Upvotes: 0

Arjun Vekariya
Arjun Vekariya

Reputation: 976

You need to specify dimension unit like dp or dip. For android:layout_height attribute use "350dp" instead of "350".

Hope this helps.

Upvotes: 10

Ranjithkumar
Ranjithkumar

Reputation: 18396

You must give the valid height

Use match_parent or wrap_content or valid dimensions

android:layout_height="350dp" //right one

You may be mistakenly give the wrong height

android:layout_height="350"  //wrong one

Upvotes: 4

Related Questions