yummypets / stevia.kt Goto Github PK
View Code? Open in Web Editor NEW:leaves: Healthy ConstraintLayout Sugar
License: MIT License
:leaves: Healthy ConstraintLayout Sugar
License: MIT License
This is the activity layout:
`ConstraintLayout(currentActivity).subviews(
flowStorage.asView(),
bottomNavigation,
blockConstraint
)
when I navigate from notification it gives :
The specified child already has a parent. You must call removeView() on the child's parent first.
How to solve this?
tried this https://stackoverflow.com/questions/28071349/the-specified-child-already-has-a-parent-you-must-call-removeview-on-the-chil but nothing helped
`
When trying to lay out views, I want to achieve something that looks like this:
The following code achieves what I want:
proteinLabel.centerInParent()
fatLabel
.constrainRightToRightOf(proteinLabel)
.constrainBottomToTopOf(proteinLabel, 40)
carbLabel
.constrainRightToRightOf(proteinLabel)
.constrainTopToBottomOf(proteinLabel, 40)
But I like how visually intuitive the layout()
function is. I would expect something like
layout(
"",
fatLabel.constrainRightToRightOf(proteinLabel),
40,
I - proteinLabel.centerVertically() - I,
40,
carbLabel.constrainRightToRightOf(proteinLabel),
""
)
would achieve the same result as the first snippet, but that doesn't seem to be the case. Instead, I get the following:
Is there a way to achieve the layout I'm after using the layout()
method? Otherwise, I don't know that I gain a whole lot over the visual design representation, especially as the number of subviews grows and increases the complexity and number of constraints.
For example, creating a view like this doesn't seem to be easy with Stevia:
Whereas it's simple with the design editor:
Stevia.kt is brilliant for UI layout on Android. However, it is not perfect, for instance, I-password-forgot-I, only layout horizontally for first item.
// code snippet from the lib
// Embedded Horizontal layout.
(item as? Array)?.let { horizontalLayout ->
// Take first "View" type in the array to layout.
var secondItem = if (horizontalLayout.count() > 1) horizontalLayout[1] else null
var firstView = (horizontalLayout.firstOrNull() as? View)
?: (secondItem as? View)
firstView?.let {
layoutView(it)
}
}
The expecting result should be layout horizontally for all item.
Is there any plan to improve this library?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.