Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic resize not working #26

Open
victorlsn opened this issue Dec 6, 2019 · 5 comments
Open

Dynamic resize not working #26

victorlsn opened this issue Dec 6, 2019 · 5 comments

Comments

@victorlsn
Copy link

I have a view which contains multiple textviews which will be "part of the ticket", but when I increase one of the textviews number of lines from 1 to 2, it works on the preview, but in real-time execution the resize doesn't work.

`
<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">

<androidx.appcompat.widget.Toolbar
android:id="@+id/fakeToolbar"
android:layout_width="match_parent"
android:layout_height="0dp"
android:backgroundTint="?attr/transparent"
android:elevation="1dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_percent="0.08"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/ticketPreviewLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="?attr/darkBackgroundColor"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/fakeToolbar">

<com.vipulasri.ticketview.TicketView
  android:id="@+id/ticketView"
  android:layout_width="match_parent"
  android:layout_height="0dp"
  android:layout_margin="16dp"
  android:elevation="4dp"
  app:layout_constraintBottom_toBottomOf="parent"
  app:layout_constraintEnd_toEndOf="parent"
  app:layout_constraintStart_toStartOf="parent"
  app:layout_constraintTop_toTopOf="parent"
  app:ticketCornerRadius="4dp"
  app:ticketCornerType="rounded"
  app:ticketOrientation="vertical"
  app:ticketScallopRadius="12dp"/>

<TextView
  android:id="@+id/ticketValidity"
  android:layout_width="0dp"
  android:layout_height="wrap_content"
  android:layout_marginStart="12dp"
  android:elevation="4dp"
  android:text="gültig in 110 • 1 Stunde"
  android:textColor="?attr/secondaryTextColor"
  android:textSize="16sp"
  app:layout_constraintBottom_toTopOf="@+id/ticketType"
  app:layout_constraintEnd_toStartOf="@+id/ticketPrice"
  app:layout_constraintStart_toStartOf="@id/ticketView"
  app:layout_constraintTop_toTopOf="@id/ticketPrice"
  app:layout_constraintVertical_bias="0" />

<TextView
  android:id="@+id/ticketPrice"
  android:layout_width="0dp"
  android:layout_height="wrap_content"
  android:layout_marginEnd="12dp"
  android:elevation="4dp"
  android:text="2,70 €"
  app:layout_constraintBottom_toTopOf="@id/ticketPriceLevel"
  android:textColor="?attr/defaultTextColor"
  android:textStyle="bold"
  android:textSize="16sp"
  android:layout_marginTop="12dp"
  app:layout_constraintEnd_toEndOf="@id/ticketView"
  app:layout_constraintTop_toTopOf="@id/ticketView" />

<TextView
  android:id="@+id/ticketPriceLevel"
  android:layout_width="0dp"
  android:layout_height="wrap_content"
  android:layout_marginEnd="12dp"
  android:elevation="4dp"
  android:layout_marginBottom="8dp"
  android:text="Preisstufe 1"
  android:textColor="?attr/secondaryTextColor"
  android:textSize="16sp"
  app:layout_constraintVertical_bias="0"
  android:textStyle="bold"
  app:layout_constraintBottom_toTopOf="@+id/ticketType"
  app:layout_constraintEnd_toEndOf="@id/ticketView"
  app:layout_constraintTop_toBottomOf="@id/ticketPrice" />

<TextView
  android:id="@+id/ticketType"
  android:layout_width="0dp"
  android:layout_height="wrap_content"
  android:layout_marginStart="12dp"
  android:layout_marginEnd="12dp"
  android:elevation="4dp"
  android:text="Einzelfahrkarte"
  android:maxLines="2"
  android:textColor="?attr/themeTextColor"
  android:textSize="22sp"
  android:textStyle="bold"
  app:layout_constraintEnd_toEndOf="@id/ticketView"
  app:layout_constraintBottom_toBottomOf="@id/ticketView"
  app:layout_constraintStart_toStartOf="@id/ticketView"
  app:layout_constraintTop_toTopOf="@id/ticketView" />

<TextView
  android:id="@+id/ticketBought"
  android:layout_width="0dp"
  android:layout_height="wrap_content"
  android:layout_marginEnd="12dp"
  android:elevation="4dp"
  android:text="Gekauft:"
  android:textColor="?attr/secondaryTextColor"
  android:textStyle="bold"
  android:textSize="16sp"
  android:layout_marginTop="8dp"
  app:layout_constraintEnd_toEndOf="@id/ticketView"
  app:layout_constraintVertical_bias="1"
  app:layout_constraintTop_toBottomOf="@id/ticketType"
  app:layout_constraintBottom_toTopOf="@id/ticketBoughtDate" />

<TextView
  android:id="@+id/ticketBoughtDate"
  android:layout_width="0dp"
  android:layout_height="wrap_content"
  android:layout_marginEnd="12dp"
  android:layout_marginBottom="20dp"
  android:elevation="4dp"
  android:text="Heute 12:20"
  app:layout_constraintTop_toBottomOf="@id/ticketBought"
  android:textColor="?attr/defaultTextColor"
  android:textSize="16sp"
  app:layout_constraintVertical_bias="0"
  android:textStyle="bold"
  app:layout_constraintBottom_toBottomOf="@+id/ticketView"
  app:layout_constraintEnd_toEndOf="@id/ticketView" />

<TextView
  android:id="@+id/ticketRemainingValidity"
  android:layout_width="0dp"
  android:layout_height="wrap_content"
  android:layout_marginStart="12dp"
  android:elevation="4dp"
  android:text="Noch 25 min gültig"
  android:textColor="?attr/defaultTextColor"
  android:textSize="18sp"
  android:textStyle="bold"
  app:layout_constraintBottom_toBottomOf="@id/ticketBoughtDate"
  app:layout_constraintEnd_toStartOf="@+id/ticketBoughtDate"
  app:layout_constraintStart_toStartOf="@id/ticketView" />

</androidx.constraintlayout.widget.ConstraintLayout>

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="?attr/surfaceColor"
android:padding="4dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ticketPreviewLayout" />

</androidx.constraintlayout.widget.ConstraintLayout>`

@molundb
Copy link

molundb commented Jan 7, 2021

I have the same issue.

@mwshubham
Copy link

@vipulasri sir

I have made a minor change to support the dynamic size ticket view. Please refer to the screenshot.

I am using two ticket views and thus will have the advantage of changing ticket colors as well. Let me if I can share make a PR for the same.
1

@vipulasri
Copy link
Owner

vipulasri commented Jan 7, 2021

@mwshubham seems like a performance heavy solution. Can you please elaborate on the actual issue you are facing?

@mwshubham
Copy link

It is not a performance heavy solution but rather not useful for many as it is a specific use case. But we can have a similar feature to have different top and bottom colors. The reason why it is not performance heavy is that I am achieving the same via special cases when scallop percentage is either 100 (for top ticket) and 0 for the bottom ticket. In the former case, I am not drawing the bottom line and arcs and top line and arcs for later.

@vipulasri
Copy link
Owner

@mwshubham can you show me some screenshots for the same? I mean the desired result

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants