From fe9f146f29c677fc164b613a1b900e045366586f Mon Sep 17 00:00:00 2001 From: whycq <913841844@qq.com> Date: 星期六, 04 一月 2025 08:25:36 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' into master --- app/src/main/res/values/styles.xml | 9 ++ app/src/main/java/com/example/customBtn/CustomBtn.java | 38 +++++++++ app/src/main/res/values/customColors.xml | 7 + app/src/main/res/layout/activity_main.xml | 158 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 210 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/example/customBtn/CustomBtn.java b/app/src/main/java/com/example/customBtn/CustomBtn.java new file mode 100644 index 0000000..05ac3db --- /dev/null +++ b/app/src/main/java/com/example/customBtn/CustomBtn.java @@ -0,0 +1,38 @@ +package com.example.customBtn; + +import android.content.Context; +import android.content.res.ColorStateList; +import android.content.res.TypedArray; +import android.util.AttributeSet; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.core.content.ContextCompat; + +import com.example.agvcontroller.R; +import com.google.android.material.button.MaterialButton; + +public class CustomBtn extends MaterialButton { + + public CustomBtn(@NonNull Context context) { + super(context); + init(context, null); + } + + public CustomBtn(@NonNull Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + } + + public CustomBtn(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + private void init(Context context, @Nullable AttributeSet attrs) { + setBackgroundTintList(null); + ColorStateList colorStateList = ContextCompat.getColorStateList(context, R.color.bulue_100); + if (colorStateList != null) { + setBackgroundTintList(colorStateList); + } + //setBackgroundColor(getResources().getColor(R.color.bulue_100,null)); + } +} diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 35a1f3b..3adc450 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -94,7 +94,7 @@ android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="6" - android:visibility="visible"> + android:visibility="gone"> <Button android:id="@+id/btn_stop2" @@ -112,7 +112,7 @@ android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginTop="10sp" - android:backgroundTint="#2196F3" + android:backgroundTint="@color/bulue.500" android:minWidth="10dp" android:paddingLeft="10dp" android:paddingRight="10dp" @@ -468,6 +468,160 @@ </RelativeLayout> + <!-- **************** 18杞� **************** --> + <GridLayout + android:id="@+id/layout_18" + android:visibility="visible" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="6" + android:columnCount="4" + android:rowCount="2" + android:padding="5dp"> + + + <com.example.customBtn.CustomBtn + android:id="@+id/btn_axle_1_front" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_columnWeight="1" + style="@style/CustomButtonStyle" + android:text="鍓嶈繘"/> + + <com.example.customBtn.CustomBtn + android:id="@+id/btn_axle_1_back" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_columnWeight="1" + style="@style/CustomButtonStyle" + android:text="鍚庨��"/> + + <com.example.customBtn.CustomBtn + android:id="@+id/btn_axle_2_front" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_columnWeight="1" + style="@style/CustomButtonStyle" + android:text="宸︽棆杞�"/> + + <com.example.customBtn.CustomBtn + android:id="@+id/btn_axle_2_back" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_columnWeight="1" + style="@style/CustomButtonStyle" + android:text="鍙虫棆杞�"/> + + <com.example.customBtn.CustomBtn + android:id="@+id/btn_axle_3_front" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_columnWeight="1" + style="@style/CustomButtonStyle" + android:text="宸︽棆杞�"/> + + <com.example.customBtn.CustomBtn + android:id="@+id/btn_axle_3_back" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_columnWeight="1" + style="@style/CustomButtonStyle" + android:text="鍙虫棆杞�"/> + + <com.example.customBtn.CustomBtn + android:id="@+id/btn_axle_4_front" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_columnWeight="1" + style="@style/CustomButtonStyle" + android:text="宸︽棆杞�"/> + + <com.example.customBtn.CustomBtn + android:id="@+id/btn_axle_4_back" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_columnWeight="1" + style="@style/CustomButtonStyle" + android:text="鍙虫棆杞�"/> + + <com.example.customBtn.CustomBtn + android:id="@+id/btn_axle_5_front" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_columnWeight="1" + style="@style/CustomButtonStyle" + android:text="宸︽棆杞�"/> + + <com.example.customBtn.CustomBtn + android:id="@+id/btn_axle_5_back" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_columnWeight="1" + style="@style/CustomButtonStyle" + android:text="鍙虫棆杞�"/> + <com.example.customBtn.CustomBtn + android:id="@+id/btn_axle_6_front" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_columnWeight="1" + style="@style/CustomButtonStyle" + android:text="宸︽棆杞�"/> + + <com.example.customBtn.CustomBtn + android:id="@+id/btn_axle_6_back" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_columnWeight="1" + style="@style/CustomButtonStyle" + android:text="鍙虫棆杞�"/> + <com.example.customBtn.CustomBtn + android:id="@+id/btn_axle_7_front" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_columnWeight="1" + style="@style/CustomButtonStyle" + android:text="宸︽棆杞�"/> + + <com.example.customBtn.CustomBtn + android:id="@+id/btn_axle_7_back" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_columnWeight="1" + style="@style/CustomButtonStyle" + android:text="鍙虫棆杞�"/> + <com.example.customBtn.CustomBtn + android:id="@+id/btn_axle_8_front" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_columnWeight="1" + style="@style/CustomButtonStyle" + android:text="宸︽棆杞�"/> + + <com.example.customBtn.CustomBtn + android:id="@+id/btn_axle_8_back" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_columnWeight="1" + style="@style/CustomButtonStyle" + android:text="鍙虫棆杞�"/> + <com.example.customBtn.CustomBtn + android:id="@+id/btn_axle_9_front" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_columnWeight="1" + style="@style/CustomButtonStyle" + android:text="宸︽棆杞�"/> + + <com.example.customBtn.CustomBtn + android:id="@+id/btn_axle_9_back" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_columnWeight="1" + style="@style/CustomButtonStyle" + android:text="鍙虫棆杞�"/> + + </GridLayout> + <!-- **************** 搴曢儴 **************** --> <LinearLayout android:background="#334455" diff --git a/app/src/main/res/values/customColors.xml b/app/src/main/res/values/customColors.xml new file mode 100644 index 0000000..d3a1d3e --- /dev/null +++ b/app/src/main/res/values/customColors.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <color name="bulue.100">#B2D7FF</color> + <color name="bulue.200">#91C6FF</color> + <color name="bulue.300">#91C6FF</color> + <color name="bulue.500">#2196F3</color> +</resources> \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..c193f65 --- /dev/null +++ b/app/src/main/res/values/styles.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <style name="CustomButtonStyle" parent="Widget.MaterialComponents.Button"> + <item name="backgroundTint">@color/bulue.500</item> + <item name="android:layout_margin">5dp</item> + <item name="android:paddingLeft">5dp</item> + <item name="android:paddingRight">5dp</item> + </style> +</resources> \ No newline at end of file -- Gitblit v1.9.1