添加位置信息编辑功能
This commit is contained in:
18
positions/src/main/res/drawable/btn_cancel_bg.xml
Normal file
18
positions/src/main/res/drawable/btn_cancel_bg.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- 按压状态(加深灰色) -->
|
||||
<item android:state_pressed="true">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#666666"/>
|
||||
<corners android:radius="4dp"/>
|
||||
</shape>
|
||||
</item>
|
||||
<!-- 默认状态(浅灰色) -->
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#999999"/>
|
||||
<corners android:radius="4dp"/>
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
|
||||
18
positions/src/main/res/drawable/btn_confirm_bg.xml
Normal file
18
positions/src/main/res/drawable/btn_confirm_bg.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- 按压状态(加深蓝色) -->
|
||||
<item android:state_pressed="true">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#303F9F"/>
|
||||
<corners android:radius="4dp"/>
|
||||
</shape>
|
||||
</item>
|
||||
<!-- 默认状态(标准蓝色) -->
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#3F51B5"/>
|
||||
<corners android:radius="4dp"/>
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
|
||||
16
positions/src/main/res/drawable/btn_delete_bg.xml
Normal file
16
positions/src/main/res/drawable/btn_delete_bg.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#D32F2F"/>
|
||||
<corners android:radius="4dp"/>
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#F44336"/>
|
||||
<corners android:radius="4dp"/>
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
|
||||
18
positions/src/main/res/drawable/edittext_bg.xml
Normal file
18
positions/src/main/res/drawable/edittext_bg.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?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="#FFFFFF"/>
|
||||
<stroke android:width="1.5dp" android:color="#4A90E2"/>
|
||||
<corners android:radius="4dp"/>
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#FFFFFF"/>
|
||||
<stroke android:width="1dp" android:color="#DDDDDD"/>
|
||||
<corners android:radius="4dp"/>
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
|
||||
18
positions/src/main/res/drawable/item_position_bg.xml
Normal file
18
positions/src/main/res/drawable/item_position_bg.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#F5F5F5"/>
|
||||
<stroke android:width="1dp" android:color="#DDDDDD"/>
|
||||
<corners android:radius="4dp"/>
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#FFFFFF"/>
|
||||
<stroke android:width="1dp" android:color="#DDDDDD"/>
|
||||
<corners android:radius="4dp"/>
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 根布局改为RelativeLayout,支持悬浮按钮绝对定位(右下角) -->
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="20dp">
|
||||
|
||||
<!-- 原有内容:经纬度显示区域(保持居中) -->
|
||||
<!-- 1. 经纬度显示区域(保持居中,上方) -->
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_location_info"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="30dp"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_horizontal">
|
||||
|
||||
@@ -27,7 +28,8 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="当前经度:等待更新..."
|
||||
android:textSize="18sp"/>
|
||||
android:textSize="18sp"
|
||||
android:layout_marginTop="15dp"/>
|
||||
|
||||
<!-- 纬度显示 -->
|
||||
<TextView
|
||||
@@ -35,11 +37,22 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="当前纬度:等待更新..."
|
||||
android:textSize="18sp"/>
|
||||
android:textSize="18sp"
|
||||
android:layout_marginTop="10dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- 新增:右下角圆形悬浮按钮(中间显示大写P字母) -->
|
||||
<!-- 2. 新增:位置列表(RecyclerView)- 位于经纬度下方,悬浮按钮上方 -->
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_position_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@id/layout_location_info"
|
||||
android:layout_above="@id/fab_p_button"
|
||||
android:layout_marginTop="20dp"
|
||||
android:paddingBottom="10dp"/>
|
||||
|
||||
<!-- 3. 右下角圆形悬浮按钮(不变) -->
|
||||
<Button
|
||||
android:id="@+id/fab_p_button"
|
||||
android:layout_width="60dp"
|
||||
|
||||
41
positions/src/main/res/layout/dialog_edit_position.xml
Normal file
41
positions/src/main/res/layout/dialog_edit_position.xml
Normal file
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 编辑视图布局:垂直排列(经纬度显示+备注输入框),带内边距确保美观 -->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="16dp">
|
||||
|
||||
<!-- 1. 经度显示(灰色小字体,不可编辑) -->
|
||||
<TextView
|
||||
android:id="@+id/tv_edit_longitude"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:textColor="#666666"
|
||||
android:layout_marginBottom="8dp"/>
|
||||
|
||||
<!-- 2. 纬度显示(灰色小字体,不可编辑) -->
|
||||
<TextView
|
||||
android:id="@+id/tv_edit_latitude"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:textColor="#666666"
|
||||
android:layout_marginBottom="16dp"/>
|
||||
|
||||
<!-- 3. 备注输入框(可编辑,带提示文字,适配多行输入) -->
|
||||
<EditText
|
||||
android:id="@+id/et_edit_memo"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="请输入位置备注(如:公司/家/学校)"
|
||||
android:textSize="16sp"
|
||||
android:inputType="textMultiLine"
|
||||
android:minLines="3"
|
||||
android:maxLines="5"
|
||||
android:padding="10dp"
|
||||
android:background="@drawable/edittext_bg"/> <!-- 输入框背景(带边框,区分普通文本) -->
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
60
positions/src/main/res/layout/item_position.xml
Normal file
60
positions/src/main/res/layout/item_position.xml
Normal file
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 列表项布局:左侧显示经纬度/备注,右侧添加删除按钮 -->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:padding="12dp"
|
||||
android:background="@drawable/item_position_bg"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:gravity="center_vertical"> <!-- 内容与按钮垂直居中对齐 -->
|
||||
|
||||
<!-- 左侧:内容区(经纬度+备注,垂直排列,占满剩余宽度) -->
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:clickable="false"> <!-- 内容区禁止点击响应 -->
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_item_longitude"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:textColor="#666666"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_item_latitude"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:textColor="#666666"
|
||||
android:layout_marginTop="5dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_item_memo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="16sp"
|
||||
android:textColor="#000000"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginTop="8dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- 右侧:删除按钮(红色图标/文字,仅按钮可点击) -->
|
||||
<Button
|
||||
android:id="@+id/btn_item_delete"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginStart="10dp"
|
||||
android:background="@drawable/btn_delete_bg"
|
||||
android:text="删除"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="12sp"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingEnd="12dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
105
positions/src/main/res/layout/item_position_edit.xml
Normal file
105
positions/src/main/res/layout/item_position_edit.xml
Normal file
@@ -0,0 +1,105 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 编辑视图:按钮顺序改为【删除(左)→取消→确定(右)】,新增取消按钮 -->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="12dp"
|
||||
android:background="@drawable/item_position_bg"
|
||||
android:layout_marginBottom="8dp">
|
||||
|
||||
<!-- 1. 经纬度显示(不变) -->
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_marginBottom="12dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_edit_longitude"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:textColor="#666666"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_edit_latitude"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:textColor="#666666"
|
||||
android:layout_marginTop="5dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- 2. 备注输入框(不变) -->
|
||||
<EditText
|
||||
android:id="@+id/et_edit_memo"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="请输入位置备注(如:公司/家/学校)"
|
||||
android:textSize="16sp"
|
||||
android:inputType="textMultiLine"
|
||||
android:minLines="2"
|
||||
android:maxLines="4"
|
||||
android:padding="10dp"
|
||||
android:background="@drawable/edittext_bg"
|
||||
android:layout_marginBottom="12dp"/>
|
||||
|
||||
<!-- 3. 按钮区(核心修改:顺序→删除(左)→取消→确定(右),新增取消按钮) -->
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<!-- ① 删除按钮(最左侧,红色) -->
|
||||
<Button
|
||||
android:id="@+id/btn_edit_delete"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="32dp"
|
||||
android:background="@drawable/btn_delete_bg"
|
||||
android:text="删除"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="13sp"
|
||||
android:paddingStart="15dp"
|
||||
android:paddingEnd="15dp"/>
|
||||
|
||||
<!-- 间隔(按钮间间距) -->
|
||||
<View
|
||||
android:layout_width="10dp"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
<!-- ② 新增:取消按钮(中间,灰色,不保存返回简单视图) -->
|
||||
<Button
|
||||
android:id="@+id/btn_edit_cancel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="32dp"
|
||||
android:background="@drawable/btn_cancel_bg"
|
||||
android:text="取消"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="13sp"
|
||||
android:paddingStart="15dp"
|
||||
android:paddingEnd="15dp"/>
|
||||
|
||||
<!-- 间隔 -->
|
||||
<View
|
||||
android:layout_width="10dp"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
<!-- ③ 确定按钮(最右侧,蓝色,保存并返回简单视图) -->
|
||||
<Button
|
||||
android:id="@+id/btn_edit_confirm"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="32dp"
|
||||
android:background="@drawable/btn_confirm_bg"
|
||||
android:text="确定"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="13sp"
|
||||
android:paddingStart="15dp"
|
||||
android:paddingEnd="15dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
39
positions/src/main/res/layout/item_position_simple.xml
Normal file
39
positions/src/main/res/layout/item_position_simple.xml
Normal file
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 简单视图:仅显示经纬度+备注,无任何按钮 -->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="12dp"
|
||||
android:background="@drawable/item_position_bg"
|
||||
android:layout_marginBottom="8dp">
|
||||
|
||||
<!-- 经度 -->
|
||||
<TextView
|
||||
android:id="@+id/tv_simple_longitude"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:textColor="#666666"/>
|
||||
|
||||
<!-- 纬度 -->
|
||||
<TextView
|
||||
android:id="@+id/tv_simple_latitude"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:textColor="#666666"
|
||||
android:layout_marginTop="5dp"/>
|
||||
|
||||
<!-- 备注(加粗突出) -->
|
||||
<TextView
|
||||
android:id="@+id/tv_simple_memo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="16sp"
|
||||
android:textColor="#000000"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginTop="8dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
9
positions/src/main/res/menu/menu_item_edit.xml
Normal file
9
positions/src/main/res/menu/menu_item_edit.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- 编辑菜单:点击后切换到编辑视图 -->
|
||||
<item
|
||||
android:id="@+id/menu_edit"
|
||||
android:title="编辑"
|
||||
android:orderInCategory="100"
|
||||
android:showAsAction="never"/> <!-- 仅在菜单中显示,不显示在按钮栏 -->
|
||||
</menu>
|
||||
Reference in New Issue
Block a user