Skip to content

Commit

Permalink
优化选中效果UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Potato-66 committed Mar 25, 2024
1 parent 1244c73 commit 96c7717
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ abstract class BaseDialogFragment<T : ViewDataBinding> : DialogFragment() {
window.attributes = params
}
it.setOnKeyListener { _, _, keyEvent ->
if (keyEvent.keyCode == KeyEvent.KEYCODE_BACK) {
if (keyEvent.keyCode == KeyEvent.KEYCODE_BACK && tag != Constant.DIALOG_TAG_UPDATE) {
dismiss()
true
} else {
Expand Down
19 changes: 4 additions & 15 deletions app/src/main/res/drawable/btn_selector.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true">
<shape android:shape="rectangle">
<solid android:color="@color/item_color" />
<corners android:radius="10dp" />
<padding android:left="10dp" android:right="10dp" />
</shape>
</item>
<item android:state_pressed="true">
<shape android:shape="rectangle">
<solid android:color="@color/item_color" />
<corners android:radius="10dp" />
<padding android:left="10dp" android:right="10dp" />
</shape>
</item>
<item android:drawable="@drawable/focus_bg" android:state_pressed="true" />
<item android:drawable="@drawable/focus_bg" android:state_focused="true" />
<item>
<shape android:shape="rectangle">
<solid android:color="@color/switch_on_color" />
<corners android:radius="10dp" />
<corners android:radius="5dp" />
<padding android:left="10dp" android:right="10dp" />
</shape>
</item>
</selector>
19 changes: 19 additions & 0 deletions app/src/main/res/drawable/focus_bg.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/white" />
<corners android:radius="5dp" />
</shape>
</item>
<item
android:bottom="1dp"
android:end="1dp"
android:start="1dp"
android:top="1dp">
<shape android:shape="rectangle">
<solid android:color="@color/item_color" />
<corners android:radius="5dp" />
</shape>
</item>
</layer-list>
6 changes: 3 additions & 3 deletions app/src/main/res/drawable/item_focus_selector.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/item_color" android:state_focused="true" />
<item android:drawable="@color/item_color" android:state_selected="true" />
<item android:drawable="@color/item_color" android:state_pressed="true" />
<item android:drawable="@drawable/focus_bg" android:state_focused="true" />
<item android:drawable="@drawable/focus_bg" android:state_selected="true" />
<item android:drawable="@drawable/focus_bg" android:state_pressed="true" />
<item android:drawable="@color/bg_color" />
</selector>
9 changes: 2 additions & 7 deletions app/src/main/res/drawable/switch_selector.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true">
<shape android:shape="rectangle">
<corners android:radius="10dp" />
<solid android:color="@color/item_color" />
</shape>
</item>
<item android:drawable="@drawable/focus_bg" android:state_focused="true" />
<item>
<shape android:shape="rectangle">
<corners android:radius="10dp" />
<corners android:radius="5dp" />
<solid android:color="@android:color/transparent" />
</shape>
</item>
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/layout/dialog_setting.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
android:layout_height="wrap_content"
android:background="@drawable/switch_selector"
android:checked="@{autoBoot}"
android:nextFocusUp="@id/btn_manual_update"
android:nextFocusUp="@id/btn_update_version"
android:nextFocusDown="@id/btn_manual_update"
android:padding="10dp"
android:text="@string/boot_startup"
Expand All @@ -50,7 +50,7 @@
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:nextFocusUp="@id/sw_auto_boot"
android:nextFocusDown="@id/sw_auto_boot"
android:nextFocusDown="@id/btn_update_version"
android:text="@string/manual_update" />

<Button
Expand All @@ -60,7 +60,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:nextFocusUp="@id/sw_auto_boot"
android:nextFocusUp="@id/btn_manual_update"
android:nextFocusDown="@id/sw_auto_boot"
android:text="@string/update_version" />

Expand Down

0 comments on commit 96c7717

Please sign in to comment.