Android 代码改变图片颜色android:tint="@color/main_color" android:tintMode="multiply"

这篇博客介绍了如何在Android中使用`tint`属性和`tintMode`来改变图片颜色,通过不同的颜色叠加和混合模式,实现上下层图片的交互显示效果,包括交集、非交集、变暗和变亮等视觉表现。
android:tint="@color/main_color"
android:tintMode="multiply"
<!--src_in 内部填充-->
<!--src_atop 内部填充-->
<!--src_over  方形-->
<!--screen  外部填充-->
<!--add 外部填充-->
<!--multiply 正常填充-->
  1. PorterDuff.Mode.CLEAR 所绘制不会提交到画布上。
  2. PorterDuff.Mode.SRC 显示上层绘制图片
  3. PorterDuff.Mode.DST 显示下层绘制图片
  4. PorterDuff.Mode.SRC_OVER 正常绘制显示,上下层绘制叠盖。
  5. PorterDuff.Mode.DST_OVER 上下层都显示。下层居上显示。
  6. PorterDuff.Mode.SRC_IN 取两层绘制交集。显示上层。
  7. PorterDuff.Mode.DST_IN 取两层绘制交集。显示下层。
  8. PorterDuff.Mode.SRC_OUT 取上层绘制非交集部分。
  9. PorterDuff.Mode.DST_OUT 取下层绘制非交集部分。
  10. PorterDuff.Mode.SRC_ATOP 取下层非交集部分与上层交集部分
  11. PorterDuff.Mode.DST_ATOP 取上层非交集部分与下层交集部分
  12. PorterDuff.Mode.XOR 取两层绘制非交集。两层绘制非交集。
  13. PorterDuff.Mode.DARKEN 上下层都显示。变暗
  14. PorterDuff.Mode.LIGHTEN 上下层都显示。变亮
  15. PorterDuff.Mode.MULTIPLY 取两层绘制交集
  16. PorterDuff.Mode.SCREEN 上下层都显示。
<?xml version="1.0" encoding="utf-8"?> <androidx.core.widget.NestedScrollView 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:background="@drawable/e" tools:context=".fragment.UserFragment"> <!-- 修正为正确的Fragment类名 --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <!-- 顶部用户信息区域 --> <FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/bg_welcome"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:orientation="vertical" android:padding="48dp"> <!-- 用户头像(优化尺寸适配) --> <com.google.android.material.imageview.ShapeableImageView android:id="@+id/iv_avatar" android:layout_width="80dp" android:layout_height="80dp" android:padding="2dp" android:src="@drawable/user_icon" android:scaleType="centerCrop" app:shapeAppearanceOverlay="@style/circleImageStyle" app:strokeColor="#FFFFFF" app:strokeWidth="2dp" /> <TextView android:id="@+id/tv_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="16dp" android:text="欢迎您,亲爱的花主" android:textColor="@color/white" android:textSize="18sp" android:textStyle="bold" /> </LinearLayout> </FrameLayout> <!-- 功能列表区域 --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="16dp" android:background="@drawable/bg_border" android:orientation="vertical" android:paddingStart="16dp" android:paddingEnd="16dp"> <!-- 我的订单 --> <LinearLayout android:id="@+id/myrecord" android:layout_width="match_parent" android:layout_height="48dp" android:gravity="center_vertical" android:orientation="horizontal" android:clickable="true" android:focusable="true" android:background="?attr/selectableItemBackground"> <!-- 添加点击反馈 --> <ImageView android:layout_width="24dp" android:layout_height="24dp" android:layout_marginEnd="8dp" android:src="@drawable/ic_order" android:scaleType="centerInside" app:tint="@color/text_hint" /> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="我的订单" android:textColor="@color/text_hint" android:textSize="14sp" android:textStyle="bold" /> <ImageView android:layout_width="16dp" android:layout_height="16dp" android:src="@drawable/arrow_right" android:scaleType="centerInside" /> </LinearLayout> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/divider" /> <!-- 移除冗余分割线(原代码中有重复分割线) --> <!-- 个人信息 --> <LinearLayout android:id="@+id/ll_info" android:layout_width="match_parent" android:layout_height="48dp" android:gravity="center_vertical" android:orientation="horizontal" android:clickable="true" android:focusable="true" android:background="?attr/selectableItemBackground"> <ImageView android:layout_width="24dp" android:layout_height="24dp" android:layout_marginEnd="8dp" android:src="@drawable/user_icon" android:scaleType="centerInside" app:tint="@color/text_hint" /> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="个人信息" android:textColor="@color/text_hint" android:textSize="14sp" android:textStyle="bold" /> <ImageView android:layout_width="16dp" android:layout_height="16dp" android:src="@drawable/arrow_right" android:scaleType="centerInside" /> </LinearLayout> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/divider" /> <!-- 联系客服 --> <LinearLayout android:id="@+id/ll_contact" android:layout_width="match_parent" android:layout_height="48dp" android:gravity="center_vertical" android:orientation="horizontal" android:clickable="true" android:focusable="true" android:background="?attr/selectableItemBackground"> <ImageView android:layout_width="24dp" android:layout_height="24dp" android:layout_marginEnd="8dp" android:src="@drawable/ic_contact" android:scaleType="centerInside" app:tint="@color/text_hint" /> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="联系客服" android:textColor="@color/text_hint" android:textSize="14sp" android:textStyle="bold" /> <ImageView android:layout_width="16dp" android:layout_height="16dp" android:src="@drawable/arrow_right" android:scaleType="centerInside" /> </LinearLayout> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/divider" /> <!-- 关于商店 --> <LinearLayout android:id="@+id/ll_about" android:layout_width="match_parent" android:layout_height="48dp" android:gravity="center_vertical" android:orientation="horizontal" android:clickable="true" android:focusable="true" android:background="?attr/selectableItemBackground"> <ImageView android:layout_width="24dp" android:layout_height="24dp" android:layout_marginEnd="8dp" android:src="@drawable/ic_about" android:scaleType="centerInside" app:tint="@color/text_hint" /> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="关于商店" android:textColor="@color/text_hint" android:textSize="14sp" android:textStyle="bold" /> <ImageView android:layout_width="16dp" android:layout_height="16dp" android:src="@drawable/arrow_right" android:scaleType="centerInside" /> </LinearLayout> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/divider" /> <!-- 退出登录 --> <LinearLayout android:id="@+id/ll_logout" android:layout_width="match_parent" android:layout_height="48dp" android:gravity="center_vertical" android:orientation="horizontal" android:clickable="true" android:focusable="true" android:background="?attr/selectableItemBackground"> <ImageView android:layout_width="24dp" android:layout_height="24dp" android:layout_marginEnd="8dp" android:src="@drawable/ic_logout" android:scaleType="centerInside" app:tint="@color/text_hint" /> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="退出登录" android:textColor="@color/text_hint" android:textSize="14sp" android:textStyle="bold" /> <ImageView android:layout_width="16dp" android:layout_height="16dp" android:src="@drawable/arrow_right" android:scaleType="centerInside" /> </LinearLayout> </LinearLayout> </LinearLayout> </androidx.core.widget.NestedScrollView>这是我fragment_me.xml里的代码,根据你的提示,把它补充完整,我需要完整的代码
10-30
<?xml version="1.0" encoding="utf-8"?> <androidx.core.widget.NestedScrollView 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:background="@drawable/e" tools:context=".fragment.UserFragment"> <!-- 修正为正确的Fragment类名 --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <!-- 顶部用户信息区域 --> <FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/bg_welcome"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:orientation="vertical" android:padding="48dp"> <!-- 用户头像(优化尺寸适配) --> <com.google.android.material.imageview.ShapeableImageView android:id="@+id/iv_avatar" android:layout_width="80dp" android:layout_height="80dp" android:padding="2dp" android:src="@drawable/user_icon" android:scaleType="centerCrop" app:shapeAppearanceOverlay="@style/circleImageStyle" app:strokeColor="#FFFFFF" app:strokeWidth="2dp" /> <TextView android:id="@+id/tv_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="16dp" android:text="欢迎您,亲爱的花主" android:textColor="@color/white" android:textSize="18sp" android:textStyle="bold" /> </LinearLayout> </FrameLayout> <!-- 功能列表区域 --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="16dp" android:background="@drawable/bg_border" android:orientation="vertical" android:paddingStart="16dp" android:paddingEnd="16dp"> <!-- 我的订单 --> <LinearLayout android:id="@+id/myrecord" android:layout_width="match_parent" android:layout_height="48dp" android:gravity="center_vertical" android:orientation="horizontal" android:clickable="true" android:focusable="true" android:background="?attr/selectableItemBackground"> <!-- 添加点击反馈 --> <ImageView android:layout_width="24dp" android:layout_height="24dp" android:layout_marginEnd="8dp" android:src="@drawable/ic_order" android:scaleType="centerInside" app:tint="@color/text_hint" /> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="我的订单" android:textColor="@color/text_hint" android:textSize="14sp" android:textStyle="bold" /> <ImageView android:layout_width="16dp" android:layout_height="16dp" android:src="@drawable/arrow_right" android:scaleType="centerInside" /> </LinearLayout> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/divider" /> <!-- 移除冗余分割线(原代码中有重复分割线) --> <!-- 个人信息 --> <LinearLayout android:id="@+id/ll_info" android:layout_width="match_parent" android:layout_height="48dp" android:gravity="center_vertical" android:orientation="horizontal" android:clickable="true" android:focusable="true" android:background="?attr/selectableItemBackground"> <ImageView android:layout_width="24dp" android:layout_height="24dp" android:layout_marginEnd="8dp" android:src="@drawable/user_icon" android:scaleType="centerInside" app:tint="@color/text_hint" /> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="个人信息" android:textColor="@color/text_hint" android:textSize="14sp" android:textStyle="bold" /> <ImageView android:layout_width="16dp" android:layout_height="16dp" android:src="@drawable/arrow_right" android:scaleType="centerInside" /> </LinearLayout> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/divider" /> <!-- 联系客服 --> <LinearLayout android:id="@+id/ll_contact" android:layout_width="match_parent" android:layout_height="48dp" android:gravity="center_vertical" android:orientation="horizontal" android:clickable="true" android:focusable="true" android:background="?attr/selectableItemBackground"> <ImageView android:layout_width="24dp" android:layout_height="24dp" android:layout_marginEnd="8dp" android:src="@drawable/ic_contact" android:scaleType="centerInside" app:tint="@color/text_hint" /> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="联系客服" android:textColor="@color/text_hint" android:textSize="14sp" android:textStyle="bold" /> <ImageView android:layout_width="16dp" android:layout_height="16dp" android:src="@drawable/arrow_right" android:scaleType="centerInside" /> </LinearLayout> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/divider" /> <!-- 关于商店 --> <LinearLayout android:id="@+id/ll_about" android:layout_width="match_parent" android:layout_height="48dp" android:gravity="center_vertical" android:orientation="horizontal" android:clickable="true" android:focusable="true" android:background="?attr/selectableItemBackground"> <ImageView android:layout_width="24dp" android:layout_height="24dp" android:layout_marginEnd="8dp" android:src="@drawable/ic_about" android:scaleType="centerInside" app:tint="@color/text_hint" /> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="关于商店" android:textColor="@color/text_hint" android:textSize="14sp" android:textStyle="bold" /> <ImageView android:layout_width="16dp" android:layout_height="16dp" android:src="@drawable/arrow_right" android:scaleType="centerInside" /> </LinearLayout> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/divider" /> <!-- 退出登录 --> <LinearLayout android:id="@+id/ll_logout" android:layout_width="match_parent" android:layout_height="48dp" android:gravity="center_vertical" android:orientation="horizontal" android:clickable="true" android:focusable="true" android:background="?attr/selectableItemBackground"> <ImageView android:layout_width="24dp" android:layout_height="24dp" android:layout_marginEnd="8dp" android:src="@drawable/ic_logout" android:scaleType="centerInside" app:tint="@color/text_hint" /> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="退出登录" android:textColor="@color/text_hint" android:textSize="14sp" android:textStyle="bold" /> <ImageView android:layout_width="16dp" android:layout_height="16dp" android:src="@drawable/arrow_right" android:scaleType="centerInside" /> </LinearLayout> </LinearLayout> </LinearLayout> </androidx.core.widget.NestedScrollView>我的该xml名为fragment__me,而不是activity_main.xml,这是我fragment__me里的代码,请根据你的提示,帮我修改里面的代码
10-30
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/grey_f3f3f3"> <RelativeLayout android:id="@+id/main_top_layout" android:layout_width="match_parent" android:layout_height="50dp"> <TextView android:text="@string/app_name" android:layout_width="wrap_content" android:layout_height="match_parent" android:gravity="center" android:padding="10dp" android:textStyle="bold" android:textSize="18sp" android:textColor="@color/black"/> <ImageView android:id="@+id/main_iv_search" android:layout_width="wrap_content" android:layout_height="match_parent" android:src="@mipmap/search" android:layout_alignParentEnd="true" android:padding="10dp"/> </RelativeLayout> <ListView android:id="@+id/main_lv" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@id/main_top_layout" android:padding="10dp" android:divider="@null" android:dividerHeight="6dp" android:scrollbars="none" android:background="@color/grey_f3f3f3"/> <ImageButton android:id="@+id/main_btn_more" android:layout_width="50dp" android:layout_height="50dp" android:src="@mipmap/more" android:layout_alignParentEnd="true" android:layout_alignParentBottom="true" android:layout_margin="20dp" android:background="@drawable/main_morebtn_bg"/> <Button android:id="@+id/main_btn_edit" android:layout_width="100dp" android:layout_height="50dp" android:layout_alignParentBottom="true" android:background="@drawable/main_recordbtn_bg" android:layout_toStartOf="@id/main_btn_more" android:text="@string/editone" android:textStyle="bold" android:textColor="@color/white" android:drawableLeft="@mipmap/edit" android:gravity="center_vertical"/> </RelativeLayout>
最新发布
12-21
要求参考已有的activity_add_task.xml内容如下,并给出完整的activity_edit_task.xml:<?xml version="1.0" encoding="utf-8"?> <androidx.core.widget.NestedScrollView 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:background="@color/light_background" android:fillViewport="true"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="16dp"> <!-- 标题栏 --> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:paddingBottom="16dp" android:text="创建新任务" android:textColor="@color/primary_dark" android:textSize="24sp" android:textStyle="bold" /> <!-- 必填项卡片 --> <com.google.android.material.card.MaterialCardView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="16dp" app:cardCornerRadius="12dp" app:cardElevation="4dp" app:strokeColor="@color/primary_light" app:strokeWidth="1dp"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="16dp"> <!-- 卡片标题 --> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:drawableStart="@drawable/ic_info_outline" android:drawablePadding="8dp" android:gravity="center_vertical" android:paddingBottom="12dp" android:text="必填信息" android:textColor="@color/primary_dark" android:textSize="18sp" android:textStyle="bold" /> <!-- 任务标题 --> <com.google.android.material.textfield.TextInputLayout style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="16dp" android:hint="任务标题 *" app:boxStrokeColor="@color/primary" app:errorEnabled="true"> <com.google.android.material.textfield.TextInputEditText android:id="@+id/taskTitleEditText" style="@style/CustomTextInputEditText" android:layout_width="match_parent" android:layout_height="wrap_content" /> </com.google.android.material.textfield.TextInputLayout> <!-- 分类选择 --> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="8dp" android:text="分类 *" android:textColor="@color/primary_dark" android:textSize="14sp" android:textStyle="bold" /> <!-- 分类按钮组 - 紧凑布局 --> <com.google.android.material.button.MaterialButtonToggleGroup android:id="@+id/categoryToggleGroup" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="16dp" app:selectionRequired="true" app:singleSelection="true"> </com.google.android.material.button.MaterialButtonToggleGroup> <!-- 重要性行 --> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="8dp" android:text="重要性 *" android:textColor="@color/primary_dark" android:textSize="14sp" android:textStyle="bold" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="16dp" android:gravity="center_vertical" android:orientation="horizontal" android:paddingVertical="10dp"> <RatingBar android:id="@+id/importanceRatingBar" style="@style/Widget.AppCompat.RatingBar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:isIndicator="false" android:numStars="5" android:progressBackgroundTint="@color/light_gray" android:progressTint="@color/primary" android:rating="3" android:stepSize="1" android:theme="@style/RatingBarStyle" /> <TextView android:id="@+id/ratingText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="16dp" android:text="中等" android:textColor="@color/primary_dark" android:textSize="16sp" /> </LinearLayout> <!-- 期待完成时长 - 标签和设置在同一行 --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="8dp" android:gravity="center_vertical" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginEnd="8dp" android:text="期待完成时长 *" android:textColor="@color/primary_dark" android:textSize="14sp" android:textStyle="bold" /> <TextView android:id="@+id/durationDisplay" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="0 分钟" android:textColor="@color/red" android:textSize="14sp" /> </LinearLayout> <!-- 时间增加按钮行 - 完全按照原界面设计 --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="4dp" android:orientation="horizontal"> <TextView android:id="@+id/add60TextView" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="?selectableItemBackground" android:clickable="true" android:focusable="true" android:gravity="center" android:padding="8dp" android:text="+60" android:textColor="@color/primary_dark" android:textSize="14sp" /> <TextView android:id="@+id/add30TextView" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="?selectableItemBackground" android:clickable="true" android:focusable="true" android:gravity="center" android:padding="8dp" android:text="+30" android:textColor="@color/primary_dark" android:textSize="14sp" /> <TextView android:id="@+id/add15TextView" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="?selectableItemBackground" android:clickable="true" android:focusable="true" android:gravity="center" android:padding="8dp" android:text="+15" android:textColor="@color/primary_dark" android:textSize="14sp" /> <TextView android:id="@+id/add10TextView" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="?selectableItemBackground" android:clickable="true" android:focusable="true" android:gravity="center" android:padding="8dp" android:text="+10" android:textColor="@color/primary_dark" android:textSize="14sp" /> <TextView android:id="@+id/add5TextView" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="?selectableItemBackground" android:clickable="true" android:focusable="true" android:gravity="center" android:padding="8dp" android:text="+5" android:textColor="@color/primary_dark" android:textSize="14sp" /> <TextView android:id="@+id/add1TextView" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="?selectableItemBackground" android:clickable="true" android:focusable="true" android:gravity="center" android:padding="8dp" android:text="+1" android:textColor="@color/primary_dark" android:textSize="14sp" /> </LinearLayout> <!-- 时间减少按钮行 - 完全按照原界面设计 --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:id="@+id/reduce60TextView" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="?selectableItemBackground" android:clickable="true" android:focusable="true" android:gravity="center" android:padding="8dp" android:text="-60" android:textColor="@color/primary_dark" android:textSize="14sp" /> <TextView android:id="@+id/reduce30TextView" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="?selectableItemBackground" android:clickable="true" android:focusable="true" android:gravity="center" android:padding="8dp" android:text="-30" android:textColor="@color/primary_dark" android:textSize="14sp" /> <TextView android:id="@+id/reduce15TextView" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="?selectableItemBackground" android:clickable="true" android:focusable="true" android:gravity="center" android:padding="8dp" android:text="-15" android:textColor="@color/primary_dark" android:textSize="14sp" /> <TextView android:id="@+id/reduce10TextView" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="?selectableItemBackground" android:clickable="true" android:focusable="true" android:gravity="center" android:padding="8dp" android:text="-10" android:textColor="@color/primary_dark" android:textSize="14sp" /> <TextView android:id="@+id/reduce5TextView" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="?selectableItemBackground" android:clickable="true" android:focusable="true" android:gravity="center" android:padding="8dp" android:text="-5" android:textColor="@color/primary_dark" android:textSize="14sp" /> <TextView android:id="@+id/reduce1TextView" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="?selectableItemBackground" android:clickable="true" android:focusable="true" android:gravity="center" android:padding="8dp" android:text="-1" android:textColor="@color/primary_dark" android:textSize="14sp" /> </LinearLayout> </LinearLayout> </com.google.android.material.card.MaterialCardView> <!-- 子任务卡片 - 新增独立卡片 --> <com.google.android.material.card.MaterialCardView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="16dp" app:cardCornerRadius="12dp" app:cardElevation="4dp" app:strokeColor="@color/primary_light" app:strokeWidth="1dp"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="16dp"> <!-- 子任务标题 --> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:drawableStart="@drawable/ic_subtask" android:drawablePadding="8dp" android:gravity="center_vertical" android:paddingBottom="12dp" android:text="子任务" android:textColor="@color/primary_dark" android:textSize="18sp" android:textStyle="bold" /> <!-- 添加子任务按钮 --> <com.google.android.material.button.MaterialButton android:id="@+id/addSubtaskButton" style="@style/Widget.MaterialComponents.Button.OutlinedButton" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="8dp" android:drawableStart="@drawable/ic_add_24dp" android:drawableTint="@color/primary" android:text="添加子任务" android:textColor="@color/primary" app:iconGravity="textStart" /> <!-- 子任务列表 --> <LinearLayout android:id="@+id/subtasksContainer" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:paddingTop="2dp"> <!-- 空状态提示 --> <TextView android:id="@+id/emptySubtasksText" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:padding="24dp" android:text="暂无子任务,点击上方按钮添加" android:textColor="#888" /> </LinearLayout> </LinearLayout> </com.google.android.material.card.MaterialCardView> <!-- 可选项折叠面板 --> <com.google.android.material.card.MaterialCardView android:id="@+id/expandableCard" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="16dp" app:cardCornerRadius="12dp" app:cardElevation="2dp"> <!-- 折叠面板标题 --> <LinearLayout android:id="@+id/expandableHeader" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/selectableItemBackground" android:minHeight="56dp" android:orientation="horizontal" android:padding="16dp"> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:drawableStart="@drawable/ic_baseline_tune_24" android:drawablePadding="8dp" android:gravity="center_vertical" android:text="更多选项" android:textColor="@color/primary" android:textSize="16sp" android:textStyle="bold" /> <ImageView android:id="@+id/expandIcon" android:layout_width="24dp" android:layout_height="24dp" android:layout_gravity="center" android:src="@drawable/ic_baseline_expand_more_24" app:tint="@color/primary" /> </LinearLayout> <!-- 可选项内容(默认折叠) --> <LinearLayout android:id="@+id/expandableContent" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="40dp" android:orientation="vertical" android:padding="16dp" android:visibility="gone"> <!-- 任务执行日期 - 移动到更多选项中 --> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="8dp" android:text="任务执行日期" android:textColor="@color/primary_dark" android:textSize="14sp" android:textStyle="bold" /> <!-- 日期选项组 - 减少间距确保文本完整显示 --> <com.google.android.material.button.MaterialButtonToggleGroup android:id="@+id/dateToggleGroup" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="16dp" app:selectionRequired="true" app:singleSelection="true"> <com.google.android.material.button.MaterialButton android:id="@+id/btnToday" style="@style/CompactButton" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginEnd="2dp" android:layout_weight="1" android:text="今天" app:backgroundTint="@color/button_background_selector" /> <com.google.android.material.button.MaterialButton android:id="@+id/btnTomorrow" style="@style/CompactButton" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginEnd="2dp" android:layout_weight="1" android:text="明天" app:backgroundTint="@color/button_background_selector" /> <com.google.android.material.button.MaterialButton android:id="@+id/btnSelectDate" style="@style/CompactButton" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginEnd="2dp" android:layout_weight="1" android:text="选择日期" app:backgroundTint="@color/button_background_selector" /> <!-- 确保"没有日期"完全显示 --> <com.google.android.material.button.MaterialButton android:id="@+id/btnNoDate" style="@style/CompactButton" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1.2" android:text="没有日期" app:backgroundTint="@color/button_background_selector" /> </com.google.android.material.button.MaterialButtonToggleGroup> <!-- 父级目标 --> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="8dp" android:text="父级目标" android:textColor="@color/primary_dark" android:textSize="14sp" android:textStyle="bold" /> <com.google.android.material.textfield.TextInputLayout style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="16dp" android:hint="选择父级目标" app:boxStrokeColor="@color/primary_light" app:hintTextColor="@color/gray_500" app:startIconTint="@color/primary"> <com.google.android.material.textfield.MaterialAutoCompleteTextView android:id="@+id/parentTargetAutoComplete" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="none" android:padding="3dp" android:paddingLeft="8dp" /> </com.google.android.material.textfield.TextInputLayout> <!-- 重复选项 --> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="8dp" android:text="重复选项" android:textColor="@color/primary_dark" android:textSize="14sp" android:textStyle="bold" /> <!-- 重复选项组 - 增加"每年"选项并调整间距 --> <com.google.android.material.button.MaterialButtonToggleGroup android:id="@+id/repeatToggleGroup" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="16dp" app:selectionRequired="true" app:singleSelection="true"> <com.google.android.material.button.MaterialButton android:id="@+id/btnNoRepeat" style="@style/CompactButton" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginEnd="2dp" android:layout_weight="1" android:text="不重复" app:backgroundTint="@color/button_background_selector" /> <com.google.android.material.button.MaterialButton android:id="@+id/btnDaily" style="@style/CompactButton" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginEnd="2dp" android:layout_weight="1" android:text="每日" app:backgroundTint="@color/button_background_selector" /> <com.google.android.material.button.MaterialButton android:id="@+id/btnWeekly" style="@style/CompactButton" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginEnd="2dp" android:layout_weight="1" android:text="每周" app:backgroundTint="@color/button_background_selector" /> <com.google.android.material.button.MaterialButton android:id="@+id/btnMonthly" style="@style/CompactButton" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginEnd="2dp" android:layout_weight="1" android:text="每月" app:backgroundTint="@color/button_background_selector" /> <!-- 新增每年选项 --> <com.google.android.material.button.MaterialButton android:id="@+id/btnYearly" style="@style/CompactButton" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="每年" app:backgroundTint="@color/button_background_selector" /> </com.google.android.material.button.MaterialButtonToggleGroup> <!-- 任务描述 --> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="8dp" android:text="任务描述" android:textColor="@color/primary_dark" android:textSize="14sp" android:textStyle="bold" /> <com.google.android.material.textfield.TextInputLayout style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="16dp" android:hint="详细描述任务内容..." app:boxStrokeColor="@color/primary_light" app:startIconDrawable="@drawable/ic_baseline_description_24" app:startIconTint="@color/primary"> <com.google.android.material.textfield.TextInputEditText android:id="@+id/taskDescriptionEditText" style="@style/CustomTextInputEditText" android:layout_width="match_parent" android:layout_height="120dp" android:gravity="top" android:inputType="textMultiLine" /> </com.google.android.material.textfield.TextInputLayout> <!-- 提醒设置 --> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="8dp" android:text="提醒设置" android:textColor="@color/primary_dark" android:textSize="14sp" android:textStyle="bold" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="16dp" android:orientation="vertical"> <androidx.appcompat.widget.SwitchCompat android:id="@+id/reminderSwitch" android:layout_width="match_parent" android:layout_height="wrap_content" android:checked="false" android:text="启用提醒" android:textColor="@color/gray_500" /> <LinearLayout android:id="@+id/reminderOptionsLayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="8dp" android:orientation="horizontal" android:visibility="gone"> <com.google.android.material.textfield.TextInputLayout style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginEnd="8dp" android:layout_weight="1" android:hint="提前时间" app:boxStrokeColor="@color/primary_light"> <com.google.android.material.textfield.TextInputEditText android:id="@+id/reminderTimeEditText" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="number" /> </com.google.android.material.textfield.TextInputLayout> <Spinner android:id="@+id/reminderUnitSpinner" style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" /> </LinearLayout> </LinearLayout> <!-- 任务状态 --> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="8dp" android:text="任务状态" android:textColor="@color/primary_dark" android:textSize="14sp" android:textStyle="bold" /> <com.google.android.material.button.MaterialButtonToggleGroup android:id="@+id/statusToggleGroup" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="16dp" app:selectionRequired="true" app:singleSelection="true"> <com.google.android.material.button.MaterialButton android:id="@+id/btnNotStarted" style="@style/CompactButton" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="未开始" app:backgroundTint="@color/button_background_selector" /> <com.google.android.material.button.MaterialButton android:id="@+id/btnInProgress" style="@style/CompactButton" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="进行中" app:backgroundTint="@color/button_background_selector" /> </com.google.android.material.button.MaterialButtonToggleGroup> <!-- 进度设置 --> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="8dp" android:text="进度 (%)" android:textColor="@color/primary_dark" android:textSize="14sp" android:textStyle="bold" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="16dp" android:gravity="center_vertical" android:orientation="horizontal"> <SeekBar android:id="@+id/progressSeekBar" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:max="100" android:progress="0" /> <TextView android:id="@+id/progressText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="16dp" android:text="0%" android:textColor="@color/primary_dark" android:textSize="16sp" /> </LinearLayout> <!-- 创建时机选择 --> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="8dp" android:text="创建时机" android:textColor="@color/primary_dark" android:textSize="14sp" android:textStyle="bold" /> <com.google.android.material.textfield.TextInputLayout style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="16dp" app:boxStrokeColor="@color/primary" app:startIconDrawable="@drawable/ic_baseline_access_time_24" app:startIconTint="@color/primary"> <com.google.android.material.textfield.MaterialAutoCompleteTextView android:id="@+id/creationTimingSpinner" android:layout_width="match_parent" android:layout_height="wrap_content" android:focusable="false" android:hint="选择创建时机" android:inputType="none" /> </com.google.android.material.textfield.TextInputLayout> </LinearLayout> </com.google.android.material.card.MaterialCardView> <!-- 操作按钮 --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_horizontal" android:orientation="horizontal" android:paddingTop="8dp"> <com.google.android.material.button.MaterialButton android:id="@+id/cancelButton" style="@style/CompactButton" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginEnd="8dp" android:layout_weight="1" android:text="取消" android:textColor="@color/primary_dark" app:backgroundTint="@color/light_gray" /> <com.google.android.material.button.MaterialButton android:id="@+id/createButton" style="@style/Widget.MaterialComponents.Button" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginStart="8dp" android:layout_weight="1" android:text="创建任务" android:textColor="@color/white" app:backgroundTint="@color/primary" /> </LinearLayout> </LinearLayout> </androidx.core.widget.NestedScrollView>
07-05
<?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout 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:background="@color/bg_light" tools:context=".ui.activity.ServiceCategoryActivity"> <!-- 顶部状态栏占位 --> <View android:id="@+id/status_bar_placeholder" android:layout_width="match_parent" android:layout_height="0dp" android:background="@android:color/white" app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHeight_percent="0.07" /> <!-- 顶部导航栏 --> <androidx.appcompat.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="@android:color/white" android:elevation="4dp" app:layout_constraintTop_toBottomOf="@id/status_bar_placeholder" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center_vertical"> <!-- 返回按钮 --> <ImageButton android:id="@+id/back_button" android:layout_width="48dp" android:layout_height="match_parent" android:background="@null" android:src="@drawable/ic_chevron_right" android:rotation="180" android:tint="@color/text_primary" android:contentDescription="返回" /> <!-- 标题 --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:text="服务" android:textSize="18sp" android:textColor="@color/text_primary" android:fontFamily="sans-serif-black" /> </RelativeLayout> </androidx.appcompat.widget.Toolbar> <!-- 主要内容区域 --> <androidx.core.widget.NestedScrollView android:layout_width="match_parent" android:layout_height="0dp" app:layout_constraintTop_toBottomOf="@id/toolbar" app:layout_constraintBottom_toBottomOf="parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <!-- 顶部搜索栏和门店选择 --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/white" android:padding="16dp" android:orientation="horizontal" android:gravity="center_vertical"> <!-- 搜索框 --> <LinearLayout android:id="@+id/search_container" android:layout_width="0dp" android:layout_height="40dp" android:layout_weight="1" android:background="@drawable/search_background" android:gravity="center_vertical" android:paddingHorizontal="12dp" android:orientation="horizontal"> <ImageView android:layout_width="20dp" android:layout_height="20dp" android:src="@drawable/ic_search" android:tint="@color/text_secondary" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="8dp" android:text="搜索服务项目..." android:textSize="14sp" android:textColor="@color/text_secondary" /> </LinearLayout> <!-- 选择门店按钮 --> <LinearLayout android:id="@+id/store_select_btn" android:layout_width="wrap_content" android:layout_height="40dp" android:background="@drawable/search_background" android:gravity="center_vertical" android:paddingHorizontal="12dp" android:orientation="horizontal" android:layout_marginLeft="8dp"> <ImageView android:layout_width="20dp" android:layout_height="20dp" android:src="@drawable/ic_map_marker" android:tint="@color/primary" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="6dp" android:text="选择门店" android:textSize="14sp" android:textColor="@color/text_primary" /> </LinearLayout> </LinearLayout> <!-- 服务分类区域 --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="16dp" android:orientation="vertical"> <androidx.cardview.widget.CardView android:layout_width="match_parent" android:layout_height="wrap_content" app:cardCornerRadius="16dp" app:cardElevation="4dp" app:cardBackgroundColor="@android:color/white"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="24dp" android:orientation="vertical"> <!-- 标题 --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="服务分类" android:textSize="18sp" android:textColor="@color/text_primary" android:fontFamily="sans-serif-black" android:layout_marginBottom="16dp" /> <!-- 分类网格 --> <GridLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:columnCount="2" android:rowCount="2" <!-- 洗护服务 --> <LinearLayout android:id="@+id/category_grooming" android:layout_width="0dp" android:layout_height="100dp" android:layout_columnWeight="1" android:background="@drawable/service_entrance_background" android:orientation="horizontal" android:gravity="center_vertical" android:padding="16dp" android:clickable="true" android:focusable="true" android:foreground="?attr/selectableItemBackground"> <LinearLayout android:layout_width="48dp" android:layout_height="48dp" android:background="@android:color/white" android:alpha="0.2" android:gravity="center" android:layout_marginRight="12dp"> <ImageView android:layout_width="24dp" android:layout_height="24dp" android:src="@drawable/ic_paw" android:tint="@android:color/white" /> </LinearLayout> <LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="洗护服务" android:textSize="16sp" android:textColor="@android:color/white" android:fontFamily="sans-serif-medium" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="专业清洁护理" android:textSize="12sp" android:textColor="@android:color/white" android:alpha="0.9" /> </LinearLayout> </LinearLayout> <!-- 美容造型 --> <LinearLayout android:id="@+id/category_beauty" android:layout_width="0dp" android:layout_height="100dp" android:layout_columnWeight="1" android:background="@drawable/shop_entrance_background" android:orientation="horizontal" android:gravity="center_vertical" android:padding="16dp" android:clickable="true" android:focusable="true" android:foreground="?attr/selectableItemBackground"> <LinearLayout android:layout_width="48dp" android:layout_height="48dp" android:background="@android:color/white" android:alpha="0.2" android:gravity="center" android:layout_marginRight="12dp"> <ImageView android:layout_width="24dp" android:layout_height="24dp" android:src="@drawable/ic_cut" android:tint="@android:color/white" /> </LinearLayout> <LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="美容造型" android:textSize="16sp" android:textColor="@android:color/white" android:fontFamily="sans-serif-medium" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="时尚造型设计" android:textSize="12sp" android:textColor="@android:color/white" android:alpha="0.9" /> </LinearLayout> </LinearLayout> <!-- 寄养服务 --> <LinearLayout android:id="@+id/category_boarding" android:layout_width="0dp" android:layout_height="100dp" android:layout_columnWeight="1" android:background="@drawable/pets_entrance_background" android:orientation="horizontal" android:gravity="center_vertical" android:padding="16dp" android:clickable="true" android:focusable="true" android:foreground="?attr/selectableItemBackground"> <LinearLayout android:layout_width="48dp" android:layout_height="48dp" android:background="@android:color/white" android:alpha="0.2" android:gravity="center" android:layout_marginRight="12dp"> <ImageView android:layout_width="24dp" android:layout_height="24dp" android:src="@drawable/ic_home" android:tint="@android:color/white" /> </LinearLayout> <LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="寄养服务" android:textSize="16sp" android:textColor="@android:color/white" android:fontFamily="sans-serif-medium" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="温馨托管照顾" android:textSize="12sp" android:textColor="@android:color/white" android:alpha="0.9" /> </LinearLayout> </LinearLayout> <!-- 乐园活动 --> <LinearLayout android:id="@+id/category_playground" android:layout_width="0dp" android:layout_height="100dp" android:layout_columnWeight="1" android:background="@drawable/stores_entrance_background" android:orientation="horizontal" android:gravity="center_vertical" android:padding="16dp" android:clickable="true" android:focusable="true" android:foreground="?attr/selectableItemBackground"> <LinearLayout android:layout_width="48dp" android:layout_height="48dp" android:background="@android:color/white" android:alpha="0.2" android:gravity="center" android:layout_marginRight="12dp"> <ImageView android:layout_width="24dp" android:layout_height="24dp" android:src="@drawable/ic_order" android:tint="@android:color/white" /> </LinearLayout> <LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="乐园活动" android:textSize="16sp" android:textColor="@android:color/white" android:fontFamily="sans-serif-medium" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="互动娱乐体验" android:textSize="12sp" android:textColor="@android:color/white" android:alpha="0.9" /> </LinearLayout> </LinearLayout> </LinearLayout> </LinearLayout> </LinearLayout> </androidx.core.widget.NestedScrollView> <!-- 精选服务推荐 --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingHorizontal="16dp" android:paddingBottom="16dp" android:orientation="vertical" tools:ignore="MissingConstraints"> <!-- 标题和查看更多 --> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" android:paddingVertical="8dp"> <TextView android:id="@+id/featured_services_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="精选服务" android:textSize="18sp" android:textColor="@color/text_primary" android:fontFamily="sans-serif-black" /> <TextView android:id="@+id/more_featured_services" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:text="查看更多" android:textSize="14sp" android:textColor="@color/primary" android:fontFamily="sans-serif-medium" android:clickable="true" android:focusable="true" android:foreground="?attr/selectableItemBackground" /> </RelativeLayout> <!-- 精选服务列表 --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <!-- 精选服务1 --> <androidx.cardview.widget.CardView android:id="@+id/featured_service_1" android:layout_width="match_parent" android:layout_height="wrap_content" app:cardCornerRadius="16dp" app:cardElevation="2dp" app:cardBackgroundColor="@android:color/white" android:clickable="true" android:focusable="true" android:foreground="?attr/selectableItemBackground"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="16dp" android:orientation="horizontal" android:gravity="center_vertical"> <ImageView android:layout_width="64dp" android:layout_height="64dp" android:src="@drawable/service_image_placeholder" android:scaleType="centerCrop" android:layout_marginRight="12dp" /> <LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="专业洗护服务" android:textSize="16sp" android:textColor="@color/text_primary" android:fontFamily="sans-serif-medium" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="深层清洁,让爱宠焕然一新" android:textSize="12sp" android:textColor="@color/text_secondary" android:layout_marginVertical="4dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="宠爱宠物医院" android:textSize="12sp" android:textColor="@color/text_secondary" /> </LinearLayout> </LinearLayout> </androidx.cardview.widget.CardView> <!-- 精选服务2 --> <androidx.cardview.widget.CardView android:id="@+id/featured_service_2" android:layout_width="match_parent" android:layout_height="wrap_content" app:cardCornerRadius="16dp" app:cardElevation="2dp" app:cardBackgroundColor="@android:color/white" android:clickable="true" android:focusable="true" android:foreground="?attr/selectableItemBackground"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="16dp" android:orientation="horizontal" android:gravity="center_vertical"> <ImageView android:layout_width="64dp" android:layout_height="64dp" android:src="@drawable/service_image_placeholder" android:scaleType="centerCrop" android:layout_marginRight="12dp" /> <LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="美容造型" android:textSize="16sp" android:textColor="@color/text_primary" android:fontFamily="sans-serif-medium" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="专业造型师,打造时尚爱宠" android:textSize="12sp" android:textColor="@color/text_secondary" android:layout_marginVertical="4dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="萌宠造型屋" android:textSize="12sp" android:textColor="@color/text_secondary" /> </LinearLayout> </LinearLayout> </androidx.cardview.widget.CardView> <!-- 精选服务3 --> <androidx.cardview.widget.CardView android:id="@+id/featured_service_3" android:layout_width="match_parent" android:layout_height="wrap_content" app:cardCornerRadius="16dp" app:cardElevation="2dp" app:cardBackgroundColor="@android:color/white" android:clickable="true" android:focusable="true" android:foreground="?attr/selectableItemBackground"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="16dp" android:orientation="horizontal" android:gravity="center_vertical"> <ImageView android:layout_width="64dp" android:layout_height="64dp" android:src="@drawable/service_image_placeholder" android:scaleType="centerCrop" android:layout_marginRight="12dp" /> <LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="豪华寄养" android:textSize="16sp" android:textColor="@color/text_primary" android:fontFamily="sans-serif-medium" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="24小时看护,如家般温暖" android:textSize="12sp" android:textColor="@color/text_secondary" android:layout_marginVertical="4dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="温馨宠物之家" android:textSize="12sp" android:textColor="@color/text_secondary" /> </LinearLayout> </LinearLayout> </androidx.cardview.widget.CardView> <!-- 精选服务4 --> <androidx.cardview.widget.CardView android:id="@+id/featured_service_4" android:layout_width="match_parent" android:layout_height="wrap_content" app:cardCornerRadius="16dp" app:cardElevation="2dp" app:cardBackgroundColor="@android:color/white" android:clickable="true" android:focusable="true" android:foreground="?attr/selectableItemBackground"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="16dp" android:orientation="horizontal" android:gravity="center_vertical"> <ImageView android:layout_width="64dp" android:layout_height="64dp" android:src="@drawable/service_image_placeholder" android:scaleType="centerCrop" android:layout_marginRight="12dp" /> <LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="乐园互动" android:textSize="16sp" android:textColor="@color/text_primary" android:fontFamily="sans-serif-medium" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="社交游戏,快乐成长时光" android:textSize="12sp" android:textColor="@color/text_secondary" android:layout_marginVertical="4dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="宠物乐园" android:textSize="12sp" android:textColor="@color/text_secondary" /> </LinearLayout> </LinearLayout> </androidx.cardview.widget.CardView> </LinearLayout> </LinearLayout> <!-- 热门门店推荐 --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="16dp" android:orientation="vertical" tools:ignore="MissingConstraints"> <!-- 标题和查看更多 --> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" android:paddingVertical="8dp"> <TextView android:id="@+id/popular_stores_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="热门门店" android:textSize="18sp" android:textColor="@color/text_primary" android:fontFamily="sans-serif-black" /> <TextView android:id="@+id/more_popular_stores" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:text="查看更多" android:textSize="14sp" android:textColor="@color/primary" android:fontFamily="sans-serif-medium" android:clickable="true" android:focusable="true" android:foreground="?attr/selectableItemBackground" /> </RelativeLayout> <!-- 热门门店列表 --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <!-- 热门门店1 --> <androidx.cardview.widget.CardView android:id="@+id/popular_store_1" android:layout_width="match_parent" android:layout_height="wrap_content" app:cardCornerRadius="16dp" app:cardElevation="2dp" app:cardBackgroundColor="@android:color/white" android:clickable="true" android:focusable="true" android:foreground="?attr/selectableItemBackground"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="16dp" android:orientation="horizontal" android:gravity="center_vertical"> <ImageView android:layout_width="64dp" android:layout_height="64dp" android:src="@drawable/store_image_placeholder" android:scaleType="centerCrop" android:layout_marginRight="12dp" /> <LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="宠爱宠物医院" android:textSize="16sp" android:textColor="@color/text_primary" android:fontFamily="sans-serif-medium" /> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingVertical="4dp"> <!-- 评分 --> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="center_vertical"> <ImageView android:layout_width="12dp" android:layout_height="12dp" android:src="@drawable/ic_star" android:tint="@color/yellow_400" /> <ImageView android:layout_width="12dp" android:layout_height="12dp" android:src="@drawable/ic_star" android:tint="@color/yellow_400" /> <ImageView android:layout_width="12dp" android:layout_height="12dp" android:src="@drawable/ic_star" android:tint="@color/yellow_400" /> <ImageView android:layout_width="12dp" android:layout_height="12dp" android:src="@drawable/ic_star" android:tint="@color/yellow_400" /> <ImageView android:layout_width="12dp" android:layout_height="12dp" android:src="@drawable/ic_star" android:tint="@color/yellow_400" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="4dp" android:text="4.9分 · 1.2km" android:textSize="12sp" android:textColor="@color/text_secondary" /> </LinearLayout> </RelativeLayout> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="洗护 · 美容 · 医疗 · 寄养" android:textSize="12sp" android:textColor="@color/text_secondary" /> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/store_status_background" android:paddingHorizontal="8dp" android:paddingVertical="4dp" android:orientation="vertical"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="营业中" android:textSize="10sp" android:textColor="@color/primary" /> </LinearLayout> </LinearLayout> </androidx.cardview.widget.CardView> <!-- 热门门店2 --> <androidx.cardview.widget.CardView android:id="@+id/popular_store_2" android:layout_width="match_parent" android:layout_height="wrap_content" app:cardCornerRadius="16dp" app:cardElevation="2dp" app:cardBackgroundColor="@android:color/white" android:clickable="true" android:focusable="true" android:foreground="?attr/selectableItemBackground"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="16dp" android:orientation="horizontal" android:gravity="center_vertical"> <ImageView android:layout_width="64dp" android:layout_height="64dp" android:src="@drawable/store_image_placeholder" android:scaleType="centerCrop" android:layout_marginRight="12dp" /> <LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="萌宠造型屋" android:textSize="16sp" android:textColor="@color/text_primary" android:fontFamily="sans-serif-medium" /> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingVertical="4dp"> <!-- 评分 --> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="center_vertical"> <ImageView android:layout_width="12dp" android:layout_height="12dp" android:src="@drawable/ic_star" android:tint="@color/yellow_400" /> <ImageView android:layout_width="12dp" android:layout_height="12dp" android:src="@drawable/ic_star" android:tint="@color/yellow_400" /> <ImageView android:layout_width="12dp" android:layout_height="12dp" android:src="@drawable/ic_star" android:tint="@color/yellow_400" /> <ImageView android:layout_width="12dp" android:layout_height="12dp" android:src="@drawable/ic_star" android:tint="@color/yellow_400" /> <ImageView android:layout_width="12dp" android:layout_height="12dp" android:src="@drawable/ic_star_outline" android:tint="@color/yellow_400" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="4dp" android:text="4.7分 · 800m" android:textSize="12sp" android:textColor="@color/text_secondary" /> </LinearLayout> </RelativeLayout> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="美容 · 造型 · 洗护" android:textSize="12sp" android:textColor="@color/text_secondary" /> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/store_status_background" android:paddingHorizontal="8dp" android:paddingVertical="4dp" android:orientation="vertical"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="营业中" android:textSize="10sp" android:textColor="@color/primary" /> </LinearLayout> </LinearLayout> </androidx.cardview.widget.CardView> </LinearLayout> </LinearLayout> <!-- 底部间距 --> <View android:layout_width="match_parent" android:layout_height="40dp" tools:ignore="MissingConstraints" /> </androidx.constraintlayout.widget.ConstraintLayout> </androidx.core.widget.NestedScrollView> </androidx.constraintlayout.widget.ConstraintLayout>优化一下
12-17
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值