Skip to content

Commit 9976809

Browse files
feat(lite): 优化弹出菜单样式
- 添加三角形边框图标 - 调整弹出菜单布局,增加三角形装饰 - 优化 EasyPopupWindow 类,移除冗余代码
1 parent 59e2be8 commit 9976809

File tree

3 files changed

+33
-12
lines changed

3 files changed

+33
-12
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ public EasyPopupWindow(Context context) {
3232
public void set(List<MenuItem> menuItems, OnPopupWindowClickListener windowClickListener) {
3333
View contentView = getContentView();
3434
ListView listView = contentView.findViewById(R.id.listView);
35+
final LayoutInflater inflater = LayoutInflater.from(contentView.getContext());
3536
listView.setAdapter(new BaseAdapter() {
36-
private final LayoutInflater inflater = LayoutInflater.from(contentView.getContext());
37-
3837
@Override
3938
public int getCount() {
4039
return menuItems.size();
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)