Skip to content

Commit b02d20b

Browse files
feat(lite): 优化弹出菜单样式并添加三角形边框
- 新增 border_triangle.xml 文件,用于创建三角形边框- 修改 EasyPopupWindow 类,优化菜单项适配器初始化 - 更新 MultipleChoiceAdapterFragment 中的回调接口使用 - 重构 popup_menu_option.xml 布局,添加三角形边框并调整卡片样式
1 parent 9ee8b02 commit b02d20b

File tree

4 files changed

+34
-13
lines changed

4 files changed

+34
-13
lines changed

app/src/main/java/com/pengxh/kt/lib/fragments/adapter/MultipleChoiceAdapterFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class MultipleChoiceAdapterFragment : KotlinBaseFragment<FragmentAdapterMultiple
4949
binding.recyclerView.adapter = selectedAdapter
5050
selectedAdapter.setOnItemCheckedListener(object :
5151
MultipleChoiceAdapter.OnItemCheckedListener<String> {
52-
override fun onItemChecked(position: Int, items: ArrayList<String>) {
52+
override fun onItemChecked(items: List<String>) {
5353
Log.d(kTag, "onItemChecked => ${items.toJson()}")
5454
}
5555
})

lite/src/main/java/com/pengxh/kt/lite/widget/EasyPopupWindow.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ class EasyPopupWindow constructor(context: Context) : PopupWindow() {
2828

2929
fun set(menuItems: ArrayList<MenuItem>, windowClickListener: OnPopupWindowClickListener) {
3030
val listView = contentView.findViewById<ListView>(R.id.listView)
31+
val inflater = LayoutInflater.from(contentView.context)
3132
listView.adapter = object : BaseAdapter() {
32-
private val inflater: LayoutInflater = LayoutInflater.from(contentView.context)
33-
3433
override fun getCount(): Int {
3534
return menuItems.size
3635
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="20px"
3+
android:height="20px"
4+
android:viewportWidth="1024"
5+
android:viewportHeight="1024">
6+
<path
7+
android:fillColor="#030B14"
8+
android:pathData="M71.7,893.3l440.3,-762.7 440.3,762.7z" />
9+
</vector>
Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,29 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
2+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
44
android:layout_width="match_parent"
5-
android:layout_height="wrap_content"
6-
android:backgroundTint="#030B14"
7-
app:cardCornerRadius="@dimen/lib_dp_5">
5+
android:layout_height="wrap_content">
86

9-
<ListView
10-
android:id="@+id/listView"
7+
<View
8+
android:layout_width="@dimen/lib_dp_20"
9+
android:layout_height="@dimen/lib_dp_20"
10+
android:layout_alignParentEnd="true"
11+
android:layout_marginEnd="@dimen/lib_dp_15"
12+
android:background="@drawable/border_triangle" />
13+
14+
<androidx.cardview.widget.CardView
1115
android:layout_width="match_parent"
1216
android:layout_height="wrap_content"
13-
android:divider="@drawable/popup_list_divider"
14-
android:dividerHeight="@dimen/lib_px_1"
15-
android:scrollbars="none" />
16-
</androidx.cardview.widget.CardView>
17+
android:layout_marginTop="17dp"
18+
android:backgroundTint="#030B14"
19+
app:cardCornerRadius="@dimen/lib_dp_5">
20+
21+
<ListView
22+
android:id="@+id/listView"
23+
android:layout_width="match_parent"
24+
android:layout_height="wrap_content"
25+
android:divider="@drawable/popup_list_divider"
26+
android:dividerHeight="@dimen/lib_px_1"
27+
android:scrollbars="none" />
28+
</androidx.cardview.widget.CardView>
29+
</RelativeLayout>

0 commit comments

Comments
 (0)