Git Product home page Git Product logo

Comments (3)

camaelon avatar camaelon commented on July 16, 2024

I'm not sure I follow -- you need to provide constraints for both position and dimension, for both axis. Have you looked at https://developer.android.com/training/constraint-layout ?

from constraintlayout.

chenfei0928 avatar chenfei0928 commented on July 16, 2024

I mean, if I provide four direction constraints and their aspect ratios on the same view at the same time, then its size calculation may be problematic.

Such as this code, Its display will not be what it is expected:

┌───┬─┐
├─┬─┤ │
│ ├─┴─┤
└─┴───┘

Do I have to use guide lines to reach?

<?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="300dp"
    android:layout_height="300dp">

    <ImageView
        android:id="@+id/iv_0"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toTopOf="@id/iv_3"
        app:layout_constraintDimensionRatio="2"
        app:layout_constraintEnd_toStartOf="@id/iv_1"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        tools:src="#fcc"/>

    <ImageView
        android:id="@+id/iv_1"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toTopOf="@id/iv_2"
        app:layout_constraintDimensionRatio="0.5"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@id/iv_0"
        app:layout_constraintTop_toTopOf="parent"
        tools:src="#fcc"/>

    <ImageView
        android:id="@+id/iv_2"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintDimensionRatio="2"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@id/iv_3"
        app:layout_constraintTop_toBottomOf="@id/iv_1"
        tools:src="#fcc"/>

    <ImageView
        android:id="@+id/iv_3"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintDimensionRatio="0.5"
        app:layout_constraintEnd_toStartOf="@id/iv_2"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/iv_0"
        tools:src="#fcc"/>
</androidx.constraintlayout.widget.ConstraintLayout>

from constraintlayout.

jafu888 avatar jafu888 commented on July 16, 2024

Yes you are correct, You can create cycles. (dont!).
Internally the solver will run over and over but is limited to N (to simplify its about 8 ) passes.
Most systems like this will get smaller with each refresh.
In general it has not be a problem as people know they are build things like that.

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.