Jump to content

Code not working in Android Developer Studio

47439294839

When I checked my code it gave me the following message:

AAPT: error: '1dp' is incompatible with attribute layout_constraintHorizontal_bias (attr) float. (and 20 of the same errors)

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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"
    tools:context=".MainActivity">

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/Value"
        tools:layout_editor_absoluteX="1dp"
        tools:layout_editor_absoluteY="1dp"
        tools:ignore="MissingConstraints" />

    <Button
        android:id="@+id/ButtonN1"
        android:layout_height="50dp"
        android:layout_width="50dp"
        android:text="@string/_1"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="1dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="101dp" />

    <Button
        android:id="@+id/ButtonN2"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:text="@string/_2"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="51dp"
        app:layout_constraintVertical_bias="101dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <Button
        android:id="@+id/ButtonN3"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:text="@string/_3"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="101dp"
        app:layout_constraintVertical_bias="101dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />


    <Button
        android:id="@+id/ButtonN4"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:text="@string/_4"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="1dp"
        app:layout_constraintVertical_bias="151dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />


    <Button
        android:id="@+id/ButtonN5"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:text="@string/_5"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="51dp"
        app:layout_constraintVertical_bias="151dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />


    <Button
        android:id="@+id/ButtonN6"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:text="@string/_6"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="101dp"
        app:layout_constraintVertical_bias="151dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <Button
        android:id="@+id/ButtonN7"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:text="@string/_7"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="1dp"
        app:layout_constraintVertical_bias="201dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />


    <Button
        android:id="@+id/ButtonN8"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:text="@string/_8"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="51dp"
        app:layout_constraintVertical_bias="201dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <Button
        android:id="@+id/ButtonN9"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:text="@string/_9"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="101dp"
        app:layout_constraintVertical_bias="201dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <Button
        android:id="@+id/ButtonN0"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:text="@string/_0"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="151dp"
        app:layout_constraintVertical_bias="1dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <Button
        android:id="@+id/ButtonENTER"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:text="@string/_ENTER"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintHorizontal_bias="151dp"
        app:layout_constraintVertical_bias="51dp" />

</androidx.constraintlayout.widget.ConstraintLayout>

So if anyone knows what's wrong with my code, please let me know.

Thanks in advance.

Link to comment
Share on other sites

Link to post
Share on other sites

4 minutes ago, 47439294839 said:

app:layout_constraintHorizontal_bias="1dp"

Looks like "1dp" is an invalid value for this property.

 

Looking at the documentation it seems like the value should be a decimal representing a percentage of 1, e.g. 0.3 for 30%. But ConstraintLayouts are deprecated so you shouldn't be using them anyway...

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
Share on other sites

Link to post
Share on other sites

But what do you think I should use instead of the ConstraintLayouts?

Link to comment
Share on other sites

Link to post
Share on other sites

9 minutes ago, Sauron said:

 But ConstraintLayouts are deprecated so you shouldn't be using them anyway...

Ehr... no? They're pretty much the thing to use over stuff like RelativeLayout etc.

 

Did you confuse the ConstraintLayout from the Android Support package with the one from AndroidX? :D

https://developer.android.com/jetpack/androidx/releases/constraintlayout

That's under active development

Remember to either quote or @mention others, so they are notified of your reply

Link to comment
Share on other sites

Link to post
Share on other sites

5 minutes ago, 47439294839 said:

But what do you think I should use instead of the ConstraintLayouts?

 

3 minutes ago, Eigenvektor said:

Ehr... no? They're pretty much the thing to use over stuff like RelativeLayout etc.

Never mind, I was reading the documentation for the outdated version in the support library. You can use ConstraintLayouts so long as it's the version from the AndroidX library.

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×