mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-09 05:25:08 +01:00
Support for maxLines in Mat Spinner View
This commit is contained in:
parent
5bc80c71c5
commit
07cc4eefb3
@ -41,7 +41,7 @@ class MaterialSpinnerView @JvmOverloads constructor(context: Context, attrs: Att
|
||||
binding.titleView.text = value
|
||||
}
|
||||
|
||||
val blendedAccent = ColorUtils.blendARGB(
|
||||
private val blendedAccent = ColorUtils.blendARGB(
|
||||
context.getResourceColor(android.R.attr.colorAccent),
|
||||
context.getResourceColor(android.R.attr.textColorPrimary),
|
||||
0.5f
|
||||
@ -71,6 +71,10 @@ class MaterialSpinnerView @JvmOverloads constructor(context: Context, attrs: Att
|
||||
val entries = (a.getTextArray(R.styleable.MaterialSpinnerView_android_entries) ?: emptyArray()).map { it.toString() }
|
||||
this.entries = entries
|
||||
|
||||
val maxLines = a.getInt(R.styleable.MaterialSpinnerView_android_maxLines, 1)
|
||||
binding.titleView.maxLines = maxLines
|
||||
this.entries = entries
|
||||
|
||||
binding.detailView.text = entries.firstOrNull().orEmpty()
|
||||
|
||||
if (entries.isNotEmpty()) {
|
||||
|
@ -9,30 +9,35 @@
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/title_view"
|
||||
style="@style/TextAppearance.MaterialComponents.Body2"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginEnd="24dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
tools:text="Title"
|
||||
android:maxLines="1" />
|
||||
app:layout_constraintEnd_toStartOf="@id/halfway_point"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="Title" />
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/detail_view"
|
||||
style="@style/TextAppearance.MaterialComponents.Body2"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/dropdown_caret"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toEndOf="@+id/start_barrier"
|
||||
app:layout_constraintStart_toEndOf="@+id/halfway_point"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="Details" />
|
||||
android:ellipsize="end"
|
||||
app:layout_constraintHorizontal_chainStyle="spread_inside"
|
||||
tools:text="Details dsfdsfsdfs df sfs dfsf er sd" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/dropdown_caret"
|
||||
@ -42,21 +47,16 @@
|
||||
app:tint="?android:attr/textColorSecondary"
|
||||
android:src="@drawable/ic_expand_more_24dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/detail_view"
|
||||
app:layout_constraintTop_toTopOf="@id/detail_view"
|
||||
app:layout_constraintBottom_toBottomOf="@id/detail_view"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<androidx.constraintlayout.widget.Barrier
|
||||
android:id="@+id/start_barrier"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:barrierDirection="right"
|
||||
app:constraint_referenced_ids="halfway_point,title_view" />
|
||||
|
||||
<androidx.constraintlayout.widget.Guideline
|
||||
android:id="@+id/halfway_point"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintStart_toEndOf="@id/title_view"
|
||||
app:layout_constraintGuide_percent="0.5" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -22,6 +22,7 @@
|
||||
<declare-styleable name="MaterialSpinnerView">
|
||||
<attr name="title" format="reference|string"/>
|
||||
<attr name="android:entries"/>
|
||||
<attr name="android:maxLines"/>
|
||||
<attr name="summary" format="reference|string" />
|
||||
</declare-styleable>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user