Git Product home page Git Product logo

Comments (11)

camaelon avatar camaelon commented on July 16, 2024

Which version of 2.0 are you using? trying to replicate it it seems to work. Could you share a full layout example? Thanks

from constraintlayout.

devconsole avatar devconsole commented on July 16, 2024

It turns out the issue is more complicated than I thought. One view alone works just fine but if you add a second view that depends on the location of the first one the layout breaks. I'm using version 2.0.4.

Here's a basic example that works as expected:

<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/text"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:background="#40f02020"
        android:text="Some text"
        app:layout_constraintWidth_percent="0.5"
        app:layout_constraintWidth_max="wrap"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"/>
    
</androidx.constraintlayout.widget.ConstraintLayout>

If you add a second view that depends on the first one the layout breaks:

<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/title"
        android:background="#4020f020"
        android:text="Title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toTopOf="@+id/text"
        app:layout_constraintLeft_toLeftOf="@+id/text"
        app:layout_constraintRight_toRightOf="@+id/text"/>

    <TextView
        android:id="@+id/text"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:background="#40f02020"
        android:text="Some text"
        app:layout_constraintWidth_percent="0.5"
        app:layout_constraintWidth_max="wrap"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>

Also note that the resulting layout will look different if you change the order of declaration:

<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/text"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:background="#40f02020"
        android:text="Some text"
        app:layout_constraintWidth_percent="0.5"
        app:layout_constraintWidth_max="wrap"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"/>

    <TextView
        android:id="@+id/title"
        android:background="#4020f020"
        android:text="Title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toTopOf="@+id/text"
        app:layout_constraintLeft_toLeftOf="@+id/text"
        app:layout_constraintRight_toRightOf="@+id/text"/>

</androidx.constraintlayout.widget.ConstraintLayout>

Both layouts worked as expected in version 1.1.3.

from constraintlayout.

camaelon avatar camaelon commented on July 16, 2024

Ah great -- thanks for the update, I can reproduce. Let me look into it.

from constraintlayout.

camaelon avatar camaelon commented on July 16, 2024

Fixed in tip of tree

from constraintlayout.

devconsole avatar devconsole commented on July 16, 2024

When will this fix be released? I have tested with 2.1.0-beta02 and it still does not work.

from constraintlayout.

devconsole avatar devconsole commented on July 16, 2024

Sample:

<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">

<TextView
    android:id="@+id/label"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="4dp"
    android:background="@color/md_cyan_500"
    android:text="Label"
    app:layout_constraintLeft_toLeftOf="@id/text"
    app:layout_constraintRight_toRightOf="@id/text"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintBottom_toTopOf="@+id/text"
    app:layout_constraintVertical_chainStyle="packed"/>

<TextView
    android:id="@+id/text"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:background="@color/md_amber_500"
    android:text="Text text"
    app:layout_constraintWidth_max="wrap"
    app:layout_constraintWidth_percent="0.5"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/label"
    app:layout_constraintBottom_toBottomOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>

from constraintlayout.

devconsole avatar devconsole commented on July 16, 2024

Is anybody there?

from constraintlayout.

devconsole avatar devconsole commented on July 16, 2024

@camaelon I believe this is not fixed, could you look into this issue again, please?

from constraintlayout.

camaelon avatar camaelon commented on July 16, 2024

ok let me check again

from constraintlayout.

devconsole avatar devconsole commented on July 16, 2024

The problem still persists in version 2.1.0.

from constraintlayout.

devconsole avatar devconsole commented on July 16, 2024

The problem still persists in version 2.1.1.

from constraintlayout.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.