Skip to content

Commit

Permalink
Improve advanced style options dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
GustavoASantos committed Mar 9, 2024
1 parent 0acbf02 commit 106ee85
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,16 @@ class BarStylesListPreference(context: Context, attrs: AttributeSet?) : ListPref
portraitStyleListview.adapter = adapter
landscapeStyleListview.adapter = adapter

val view = adapter.getView(0, null, portraitStyleListview)
view.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED)
portraitStyleListview.layoutParams.height = view.measuredHeight * adapter.count
landscapeStyleListview.layoutParams.height = view.measuredHeight * adapter.count
var viewHeight = 0

for (i in 0 until adapter.count) {
val view = adapter.getView(i, null, portraitStyleListview)
view.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED)
viewHeight += view.measuredHeight
}

portraitStyleListview.layoutParams.height = viewHeight
landscapeStyleListview.layoutParams.height = viewHeight

val sharedPreferences = preferenceManager.sharedPreferences ?: return

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/advanced_style_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="@null"
android:choiceMode="singleChoice"
android:paddingBottom="8dp"/>
android:choiceMode="singleChoice" />

<TextView
style="?android:attr/windowTitleStyle"
Expand All @@ -39,6 +38,7 @@
android:singleLine="false"
android:paddingStart="?dialogPreferredPadding"
android:paddingEnd="?dialogPreferredPadding"
android:paddingTop="8dp"
android:paddingBottom="8dp"/>

<ListView
Expand Down

0 comments on commit 106ee85

Please sign in to comment.