Code Monkey home page Code Monkey logo

Comments (4)

shaurya947 avatar shaurya947 commented on September 6, 2024

Temporarily achieved this by wrapping MyContourView inside a ConstraintLayout in my fragment. The ConstraintLayout has a dummy View at the top (a "spacer") that expands to fill the space available to it. Not very satisfied though.. hoping there is a way without nesting ViewGroups like this.

from contour.

dimsuz avatar dimsuz commented on September 6, 2024

I am currently trying to achieve the same and I plan to do it like this:

Let's say my view is split into 2 parts: Main and AnchoredToBottom. If there is no space, than A follows immediately below M, otherwise spacing is added so that A appears to be anchored to the bottom

  1. In contourHeightOf: if bottom() - A.height() < M.bottom() then we have an overflow and return A.bottom() else we return it unmodified
  2. In A.applyLayout() we also check for overflow and either do A.topTo { M.bottom() } if there is an overflow or do A.topTo { M.bottom() - calculateTopMarginBasedOn(parent.height()) }

What I currently miss here is comparison operators for YInt/XInt, actually I came to file an issue and noticed your report :)

from contour.

dimsuz avatar dimsuz commented on September 6, 2024

Oops, this won't work because there's no way to know bottom() of whole contour layout in contourHeightOf { }...

from contour.

aerb avatar aerb commented on September 6, 2024

The problem with the original layout is MyContourLayout has a height that is a function of view2.bottom() and view2.bottom() is a function of MyContourLayout's height.

It's not satisfying but the solution here would be:

contourHeightOf { availableHeight ->
  maxOf(availableHeight, view1.height() + view2.height() + interItemMarginPx)
}

from contour.

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.