style(ui): 优化食物识别界面布局和对话框标题
- 将食物照片区域包装在 CardView 中并调整样式 - 为食材列表容器添加滚动指示条功能 - 替换 RecyclerView 的滚动条为自定义指示条 - 更新多个对话框的标题文本以提高一致性 - 在准备烹饪界面添加重量显示文本 - 优化适配器数据更新和列表滚动逻辑 - 防止 StateFlow 重放导致的重复数据加载 - 添加新的滚动条绘制资源文件
This commit is contained in:
@@ -8,83 +8,115 @@
|
||||
android:padding="16dp"
|
||||
tools:background="@color/white">
|
||||
|
||||
<!-- 食材照片,权重占满剩余空间 -->
|
||||
<!-- 食材照片,权重占满剩余空间 -->
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
app:cardBackgroundColor="@color/white"
|
||||
app:cardElevation="0dp"
|
||||
app:cardCornerRadius="8dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivFoodPhoto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop"
|
||||
tools:ignore="ContentDescription"
|
||||
tools:src="@color/bg_color" />
|
||||
tools:src="@mipmap/ic_launcher" />
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<!-- 识别到的食材列表,无数据时隐藏 -->
|
||||
<FrameLayout
|
||||
android:id="@+id/flListContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="260dp"
|
||||
android:layout_marginTop="12dp">
|
||||
|
||||
<!-- 识别到的食材列表,无数据时隐藏 -->
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:maxHeight="200dp"
|
||||
android:nestedScrollingEnabled="false"
|
||||
android:layout_height="match_parent"
|
||||
android:overScrollMode="never"
|
||||
android:visibility="gone"
|
||||
android:paddingEnd="6dp"
|
||||
android:paddingStart="0dp"
|
||||
android:clipToPadding="false"
|
||||
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
|
||||
app:spanCount="2"
|
||||
tools:itemCount="4"
|
||||
tools:listitem="@layout/list_item_search_goods_info"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<!-- 选中的食材名称 -->
|
||||
<TextView
|
||||
android:id="@+id/tvSelectedFood"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="90dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:gravity="center"
|
||||
android:text="-"
|
||||
android:textColor="@color/black333"
|
||||
android:textSize="32sp" />
|
||||
<View
|
||||
android:id="@+id/vScrollIndicatorTrack"
|
||||
android:layout_width="4dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="end|top"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:background="@drawable/scrollbar_track_food_recognize"
|
||||
android:visibility="gone" />
|
||||
|
||||
<!-- 秤1重量 -->
|
||||
<TextView
|
||||
android:id="@+id/tvWeight"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="90dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:background="@drawable/shape_white_12_corners"
|
||||
android:gravity="center"
|
||||
android:text="0.0 g"
|
||||
android:textColor="@color/black333"
|
||||
android:textSize="32sp" />
|
||||
<View
|
||||
android:id="@+id/vScrollIndicatorThumb"
|
||||
android:layout_width="6dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="end|top"
|
||||
android:layout_marginEnd="1dp"
|
||||
android:background="@drawable/scrollbar_thumb_food_recognize"
|
||||
android:visibility="gone" />
|
||||
</FrameLayout>
|
||||
|
||||
<!-- 更换食材 -->
|
||||
<TextView
|
||||
android:id="@+id/btnChangeFood"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="90dp"
|
||||
android:layout_marginTop="30dp"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/shape_green_bg"
|
||||
android:foreground="?android:attr/selectableItemBackground"
|
||||
android:text="更换食材"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="32sp"
|
||||
android:textStyle="bold" />
|
||||
<!-- 选中的食材名称 -->
|
||||
<TextView
|
||||
android:id="@+id/tvSelectedFood"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="90dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:gravity="center"
|
||||
android:text="-"
|
||||
android:textColor="@color/black333"
|
||||
android:textSize="32sp" />
|
||||
|
||||
<!-- 取消 -->
|
||||
<TextView
|
||||
android:id="@+id/btnCancel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="90dp"
|
||||
android:layout_marginTop="30dp"
|
||||
android:layout_marginBottom="30dp"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/shape_white_12_corners"
|
||||
android:foreground="?android:attr/selectableItemBackground"
|
||||
android:text="取消"
|
||||
android:textColor="@color/black333"
|
||||
android:textSize="32sp"
|
||||
android:textStyle="bold" />
|
||||
<!-- 秤1重量 -->
|
||||
<TextView
|
||||
android:id="@+id/tvWeight"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="90dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:background="@drawable/shape_white_12_corners"
|
||||
android:gravity="center"
|
||||
android:text="0.0 g"
|
||||
android:textColor="@color/black333"
|
||||
android:textSize="32sp" />
|
||||
|
||||
<!-- 更换食材 -->
|
||||
<TextView
|
||||
android:id="@+id/btnChangeFood"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="90dp"
|
||||
android:layout_marginTop="30dp"
|
||||
android:background="@drawable/shape_green_bg"
|
||||
android:foreground="?android:attr/selectableItemBackground"
|
||||
android:gravity="center"
|
||||
android:text="更换食材"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="32sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<!-- 取消 -->
|
||||
<TextView
|
||||
android:id="@+id/btnCancel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="90dp"
|
||||
android:layout_marginTop="30dp"
|
||||
android:layout_marginBottom="30dp"
|
||||
android:background="@drawable/shape_white_12_corners"
|
||||
android:foreground="?android:attr/selectableItemBackground"
|
||||
android:gravity="center"
|
||||
android:text="取消"
|
||||
android:textColor="@color/black333"
|
||||
android:textSize="32sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -75,6 +75,16 @@
|
||||
android:textColor="@color/black666"
|
||||
android:textSize="28sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvShowWeight"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:padding="10dp"
|
||||
tools:text="0g"
|
||||
android:textColor="@color/black666"
|
||||
android:textSize="28sp" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/flCameraContainer"
|
||||
android:layout_width="1dp"
|
||||
|
||||
Reference in New Issue
Block a user