TicketView icon indicating copy to clipboard operation
TicketView copied to clipboard

Dynamic resize not working

Open victorlsn opened this issue 6 years ago • 5 comments

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

victorlsn avatar Dec 06 '19 14:12 victorlsn

I have the same issue.

molundb avatar Jan 07 '21 10:01 molundb

@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

mwshubham avatar Jan 07 '21 13:01 mwshubham

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

vipulasri avatar Jan 07 '21 15:01 vipulasri

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.

mwshubham avatar Jan 08 '21 05:01 mwshubham

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

vipulasri avatar Jan 08 '21 05:01 vipulasri