mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-24 13:31:51 +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
|
binding.titleView.text = value
|
||||||
}
|
}
|
||||||
|
|
||||||
val blendedAccent = ColorUtils.blendARGB(
|
private val blendedAccent = ColorUtils.blendARGB(
|
||||||
context.getResourceColor(android.R.attr.colorAccent),
|
context.getResourceColor(android.R.attr.colorAccent),
|
||||||
context.getResourceColor(android.R.attr.textColorPrimary),
|
context.getResourceColor(android.R.attr.textColorPrimary),
|
||||||
0.5f
|
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() }
|
val entries = (a.getTextArray(R.styleable.MaterialSpinnerView_android_entries) ?: emptyArray()).map { it.toString() }
|
||||||
this.entries = entries
|
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()
|
binding.detailView.text = entries.firstOrNull().orEmpty()
|
||||||
|
|
||||||
if (entries.isNotEmpty()) {
|
if (entries.isNotEmpty()) {
|
||||||
|
@ -9,30 +9,35 @@
|
|||||||
<com.google.android.material.textview.MaterialTextView
|
<com.google.android.material.textview.MaterialTextView
|
||||||
android:id="@+id/title_view"
|
android:id="@+id/title_view"
|
||||||
style="@style/TextAppearance.MaterialComponents.Body2"
|
style="@style/TextAppearance.MaterialComponents.Body2"
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
android:layout_width="0dp"
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
android:layout_marginTop="12dp"
|
android:layout_marginTop="12dp"
|
||||||
|
android:layout_marginEnd="24dp"
|
||||||
android:layout_marginBottom="12dp"
|
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"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
tools:text="Title"
|
app:layout_constraintEnd_toStartOf="@id/halfway_point"
|
||||||
android:maxLines="1" />
|
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
|
<com.google.android.material.textview.MaterialTextView
|
||||||
android:id="@+id/detail_view"
|
android:id="@+id/detail_view"
|
||||||
style="@style/TextAppearance.MaterialComponents.Body2"
|
style="@style/TextAppearance.MaterialComponents.Body2"
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toStartOf="@id/dropdown_caret"
|
app:layout_constraintEnd_toStartOf="@id/dropdown_caret"
|
||||||
app:layout_constraintHorizontal_bias="0.0"
|
app:layout_constraintStart_toEndOf="@+id/halfway_point"
|
||||||
app:layout_constraintStart_toEndOf="@+id/start_barrier"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
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
|
<ImageView
|
||||||
android:id="@+id/dropdown_caret"
|
android:id="@+id/dropdown_caret"
|
||||||
@ -42,21 +47,16 @@
|
|||||||
app:tint="?android:attr/textColorSecondary"
|
app:tint="?android:attr/textColorSecondary"
|
||||||
android:src="@drawable/ic_expand_more_24dp"
|
android:src="@drawable/ic_expand_more_24dp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toEndOf="@id/detail_view"
|
||||||
app:layout_constraintTop_toTopOf="@id/detail_view"
|
app:layout_constraintTop_toTopOf="@id/detail_view"
|
||||||
app:layout_constraintBottom_toBottomOf="@id/detail_view"
|
app:layout_constraintBottom_toBottomOf="@id/detail_view"
|
||||||
tools:ignore="ContentDescription" />
|
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
|
<androidx.constraintlayout.widget.Guideline
|
||||||
android:id="@+id/halfway_point"
|
android:id="@+id/halfway_point"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
|
app:layout_constraintStart_toEndOf="@id/title_view"
|
||||||
app:layout_constraintGuide_percent="0.5" />
|
app:layout_constraintGuide_percent="0.5" />
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -22,6 +22,7 @@
|
|||||||
<declare-styleable name="MaterialSpinnerView">
|
<declare-styleable name="MaterialSpinnerView">
|
||||||
<attr name="title" format="reference|string"/>
|
<attr name="title" format="reference|string"/>
|
||||||
<attr name="android:entries"/>
|
<attr name="android:entries"/>
|
||||||
|
<attr name="android:maxLines"/>
|
||||||
<attr name="summary" format="reference|string" />
|
<attr name="summary" format="reference|string" />
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user