Add a clear button for preference filter, clean up layout a little

This commit is contained in:
Brian Quinion 2020-11-24 11:43:59 +00:00
parent eaba35c024
commit 33431bd5a8
2 changed files with 20 additions and 4 deletions

View file

@ -33,6 +33,10 @@ class PreferencesActivity : NoSplashAppCompatActivity(), PreferenceFragmentCompa
override fun afterTextChanged(s: Editable) {}
})
pref_filter_clear.setOnClickListener() {
pref_filter.setText("");
}
title = resourceHelper.gs(R.string.nav_preferences)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.setDisplayShowHomeEnabled(true)

View file

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
@ -16,15 +15,28 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_gravity="center_vertical"
android:text="@string/filter"
android:textAppearance="@android:style/TextAppearance.Material.Medium"
android:textStyle="bold" />
<EditText
android:id="@+id/pref_filter"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:inputType="text" />
<ImageView
android:id="@+id/pref_filter_clear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
app:srcCompat="@android:drawable/ic_menu_close_clear_cancel" />
</LinearLayout>
@ -36,7 +48,7 @@
<FrameLayout
android:id="@+id/frame_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"></FrameLayout>
android:layout_height="wrap_content"></FrameLayout>
</ScrollView>