Skip to content

Commit

Permalink
update(button): update joystick button style when clicking
Browse files Browse the repository at this point in the history
  • Loading branch information
ZCShou committed Aug 20, 2022
1 parent 59c138e commit ecd4abc
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 21 deletions.
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/circle_shape_bg.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/circle_shape_pressed" android:state_pressed="true" />
<item android:drawable="@drawable/circle_shape_normal" android:state_focused="false" />
</selector>
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:shape="oval">
<!-- 填充的颜色 -->
<solid android:color="#E0FFFFFF" />
<!-- 设置按钮的四个角为弧形 -->
<!-- android:radius 弧形的半径 -->
<corners android:radius="12dp" />
<!--边框的宽度及颜色-->
<stroke
android:width="3px"
android:color="@color/colorAccent" />
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:shape="oval">
<!-- 填充的颜色 -->
<solid android:color="#E0FFFFFF" />
<!-- 设置按钮的四个角为弧形 -->
<!-- android:radius 弧形的半径 -->
<corners android:radius="12dp" />
<!--边框的宽度及颜色-->
<stroke
android:width="3px"
android:color="@color/colorAccent" />
</shape>
15 changes: 15 additions & 0 deletions app/src/main/res/drawable/circle_shape_pressed.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:shape="oval">
<!-- 填充的颜色 -->
<solid android:color="#C0C0C0" />
<!-- 设置按钮的四个角为弧形 -->
<!-- android:radius 弧形的半径 -->
<corners android:radius="12dp" />
<!--边框的宽度及颜色-->
<stroke
android:width="3px"
android:color="@color/colorAccent" />
</shape>
12 changes: 6 additions & 6 deletions app/src/main/res/layout/joystick.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
android:layout_height="@dimen/joystick_ctrl_btn_height"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:background="@drawable/circle_shape"
android:background="@drawable/circle_shape_bg"
android:orientation="horizontal">

<ImageButton
Expand All @@ -37,7 +37,7 @@
android:layout_height="@dimen/joystick_ctrl_btn_height"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:background="@drawable/circle_shape"
android:background="@drawable/circle_shape_bg"
android:orientation="horizontal">
<ImageButton
android:id="@+id/joystick_history"
Expand All @@ -58,7 +58,7 @@
android:layout_height="@dimen/joystick_ctrl_btn_height"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:background="@drawable/circle_shape"
android:background="@drawable/circle_shape_bg"
android:orientation="horizontal">
<ImageButton
android:id="@+id/joystick_position"
Expand Down Expand Up @@ -90,7 +90,7 @@
android:layout_height="@dimen/joystick_ctrl_btn_height"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:background="@drawable/circle_shape"
android:background="@drawable/circle_shape_bg"
android:orientation="horizontal">
<ImageButton
android:id="@+id/joystick_walk"
Expand All @@ -111,7 +111,7 @@
android:layout_height="@dimen/joystick_ctrl_btn_height"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:background="@drawable/circle_shape"
android:background="@drawable/circle_shape_bg"
android:orientation="horizontal">
<ImageButton
android:id="@+id/joystick_run"
Expand All @@ -132,7 +132,7 @@
android:layout_height="@dimen/joystick_ctrl_btn_height"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:background="@drawable/circle_shape"
android:background="@drawable/circle_shape_bg"
android:orientation="horizontal">
<ImageButton
android:id="@+id/joystick_bike"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/joystick_map.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
android:layout_height="40dp"
android:layout_gravity="center_horizontal|center_vertical|bottom"
android:layout_marginBottom="40dp"
android:background="@drawable/circle_shape"
android:background="@drawable/circle_shape_bg"
android:contentDescription="@null"
android:src="@drawable/ic_position"
android:theme="@style/RippleWhite" />
Expand Down

0 comments on commit ecd4abc

Please sign in to comment.