Comments (11)
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.
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.
Ah great -- thanks for the update, I can reproduce. Let me look into it.
from constraintlayout.
Fixed in tip of tree
from constraintlayout.
When will this fix be released? I have tested with 2.1.0-beta02 and it still does not work.
from constraintlayout.
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.
Is anybody there?
from constraintlayout.
@camaelon I believe this is not fixed, could you look into this issue again, please?
from constraintlayout.
ok let me check again
from constraintlayout.
The problem still persists in version 2.1.0.
from constraintlayout.
The problem still persists in version 2.1.1.
from constraintlayout.
Related Issues (20)
- In Android8.1 (27), the round setting is too large, and the ImageFilterView cannot be displayed HOT 2
- Comprehensive guide/documentation for swing constraintlayout HOT 2
- Carousel changes views randomly if used inside a RecyclerView HOT 1
- setDragScale method in OnSwipe only accepts integer values
- [Compose] Multiple transitions onSwipe HOT 4
- [Compose] Layout not behaving as expected when using Dimension.fillToConstraints.atLeastWrapContent HOT 5
- I think this is definitely a bug HOT 6
- ConstraintLayoutReference.id is internal in alpha version
- MotionLayout produces incorrect animation
- Setting match_parent in a child causes display and stability problems in its descendant views
- Jetpack Compose Constraint Layout. Constraint in preview are shifted
- [Compose] MotionLayout cannot animate the circle angle and distance together HOT 2
- MotionLayout bug with Recyclerview ( setTransition programmatically and back, Recyclerview Scroll did not attach to MotionLayout OnSwipe )
- onSwipe not work when sub composable item with clickable Modifier
- Layer can't work with MotionLayout!
- MotionCompose Not Working with RememberSaveable
- App crashes when trying to animate fontSize in MotionScene for Compose
- ConstriantLayout Landscape stretching
- Textview with constrainedHeight inside a ConstraintLayout with height wrap_content expands the ConstraintLayout and prevents ellipsize
- MotionLayout OnSwipe without TouchAnchorId (support nested scroll)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from constraintlayout.