This commit is contained in:
muqing 2024-07-08 21:25:48 +08:00
parent 89d9cd3c85
commit 51b9ded659
16 changed files with 519 additions and 41 deletions

View File

@ -4,6 +4,14 @@
<selectionStates> <selectionStates>
<SelectionState runConfigName="app"> <SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" /> <option name="selectionMode" value="DROPDOWN" />
<DropdownSelection timestamp="2024-07-08T12:02:56.494753700Z">
<Target type="DEFAULT_BOOT">
<handle>
<DeviceId pluginId="PhysicalDevice" identifier="serial=MQS0219719035228" />
</handle>
</Target>
</DropdownSelection>
<DialogSelection />
</SelectionState> </SelectionState>
</selectionStates> </selectionStates>
</component> </component>

View File

@ -7,4 +7,11 @@
<component name="ProjectType"> <component name="ProjectType">
<option name="id" value="Android" /> <option name="id" value="Android" />
</component> </component>
<component name="VisualizationToolProject">
<option name="state">
<ProjectState>
<option name="scale" value="0.67" />
</ProjectState>
</option>
</component>
</project> </project>

View File

@ -1,11 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" > xmlns:tools="http://schemas.android.com/tools">
<!-- 网络权限 -->
<!-- 网络权限-->
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<!-- 支持http android:usesCleartextTraffic="true"-->
<application <application
android:name=".App" android:name=".App"
android:allowBackup="true" android:allowBackup="true"
@ -15,16 +13,25 @@
android:label="@string/app_name" android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:usesCleartextTraffic="true"
android:theme="@style/Theme.AndroidDemo" android:theme="@style/Theme.AndroidDemo"
tools:targetApi="31" > android:usesCleartextTraffic="true"
tools:targetApi="31">
<activity <activity
android:name=".activity.Toast" android:name=".activity.DefPopup"
android:exported="false" />
<activity
android:name=".activity.DefPopupMenu"
android:exported="false" />
<activity
android:name=".activity.Dialog"
android:exported="false" />
<activity
android:name=".activity.DefToast"
android:exported="false" /> android:exported="false" />
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:theme="@style/MainActivity" android:exported="true"
android:exported="true" > android:theme="@style/MainActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />

View File

@ -1,6 +1,8 @@
package com.example.androiddemo; package com.example.androiddemo;
import com.example.androiddemo.activity.Toast; import com.example.androiddemo.activity.DefPopup;
import com.example.androiddemo.activity.Dialog;
import com.example.androiddemo.activity.DefToast;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -20,7 +22,9 @@ public class Function {
} }
public static void init() { public static void init() {
list.add(new Function("多样化提示", Toast.class)); list.add(new Function("多样化提示", DefToast.class));
list.add(new Function("毛玻璃弹窗", Dialog.class));
list.add(new Function("自定义Popup", DefPopup.class));
} }

View File

@ -0,0 +1,49 @@
package com.example.androiddemo.activity;
import android.animation.AnimatorInflater;
import android.animation.AnimatorSet;
import android.app.Activity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.PopupWindow;
import android.widget.Toast;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.PopupMenu;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import com.example.androiddemo.R;
public class DefPopup extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_def_popup);
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
return insets;
});
findViewById(R.id.btn_custom).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
PopupMenu popupMenu = new PopupMenu(DefPopup.this, v);
popupMenu.getMenuInflater().inflate(R.menu.popup_menu, popupMenu.getMenu());
popupMenu.setOnMenuItemClickListener(item -> {
Toast.makeText(DefPopup.this, item.getTitle(), Toast.LENGTH_SHORT).show();
return true;
});
popupMenu.show();
}
});
}
}

View File

@ -3,19 +3,11 @@ package com.example.androiddemo.activity;
import android.animation.Animator; import android.animation.Animator;
import android.animation.AnimatorSet; import android.animation.AnimatorSet;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.app.Dialog;
import android.graphics.Bitmap;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.renderscript.Allocation;
import android.renderscript.Element;
import android.renderscript.RenderScript;
import android.renderscript.ScriptIntrinsicBlur;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.view.Gravity; import android.view.Gravity;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import androidx.activity.EdgeToEdge; import androidx.activity.EdgeToEdge;
@ -25,7 +17,6 @@ import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat; import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat; import androidx.core.view.WindowInsetsCompat;
import com.bumptech.glide.Glide;
import com.example.androiddemo.R; import com.example.androiddemo.R;
import com.example.androiddemo.databinding.ViewToastBinding; import com.example.androiddemo.databinding.ViewToastBinding;
import com.google.android.material.card.MaterialCardView; import com.google.android.material.card.MaterialCardView;
@ -33,7 +24,7 @@ import com.google.android.material.card.MaterialCardView;
/** /**
* 多样化提示界面 * 多样化提示界面
*/ */
public class Toast extends AppCompatActivity { public class DefToast extends AppCompatActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -45,7 +36,6 @@ public class Toast extends AppCompatActivity {
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom); v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
return insets; return insets;
}); });
View viewById = findViewById(R.id.TopToast);
LinearLayout linearLayout = findViewById(R.id.line1); LinearLayout linearLayout = findViewById(R.id.line1);
// 屏幕的宽度/2 // 屏幕的宽度/2
@ -57,11 +47,18 @@ public class Toast extends AppCompatActivity {
layoutParams.setMargins(0, 20, 0, 0); layoutParams.setMargins(0, 20, 0, 0);
layoutParams.gravity = Gravity.CENTER_HORIZONTAL; layoutParams.gravity = Gravity.CENTER_HORIZONTAL;
viewById.setOnClickListener(v -> linearLayout.addView(NewToast("测试"), 0, layoutParams)); findViewById(R.id.TopToast).setOnClickListener(v -> {
linearLayout.setGravity(Gravity.CENTER_HORIZONTAL);
linearLayout.addView(NewToast("测试"), 0, layoutParams);
});
findViewById(R.id.CenterToast).setOnClickListener(v -> {
linearLayout.setGravity(Gravity.CENTER);
linearLayout.addView(NewToast("测试"), 0, layoutParams);
});
Glide.with(this).load("https://pic2.zhimg.com/v2-febc9228d18886a29c68a66536279dfb_r.jpg?source=1940ef5c") // Glide.with(this).load("https://pic2.zhimg.com/v2-febc9228d18886a29c68a66536279dfb_r.jpg?source=1940ef5c")
.into((ImageView) findViewById(R.id.imageView)); // .into((ImageView) findViewById(R.id.imageView));
} }
@ -75,16 +72,14 @@ public class Toast extends AppCompatActivity {
MaterialCardView materialCardView = binding.getRoot(); MaterialCardView materialCardView = binding.getRoot();
ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(materialCardView, "scaleY", 0.8f, 1f); //创建移动动画
scaleYAnimator.setDuration(300); // 动画持续时间1秒 ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(materialCardView, "scaleY", 0.5f, 1f);
ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(materialCardView, "scaleX", 0.5f, 1f);
// 创建透明度渐变动画 scaleXAnimator.setDuration(100);
ObjectAnimator fadeInAnimator = ObjectAnimator.ofFloat(materialCardView, "alpha", 0f, 1f); scaleYAnimator.setDuration(100); // 动画持续时间1秒
fadeInAnimator.setDuration(300); // 动画持续时间1秒
// 同时播放两个动画 // 同时播放两个动画
AnimatorSet set = new AnimatorSet(); AnimatorSet set = new AnimatorSet();
set.playTogether(scaleYAnimator, fadeInAnimator); set.playTogether(scaleYAnimator,scaleXAnimator);
set.start(); set.start();
// 设置动画结束后的回调 // 设置动画结束后的回调

View File

@ -0,0 +1,208 @@
package com.example.androiddemo.activity;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.view.MenuInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;
import androidx.activity.EdgeToEdge;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.engine.GlideException;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.target.Target;
import com.example.androiddemo.R;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.dialog.MaterialDialogs;
import java.util.function.Consumer;
public class Dialog extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_dialog);
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
return insets;
});
//SDK 小于31 的关闭界面
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
android.widget.Toast.makeText(this, "只支持Android 12以上的设备", Toast.LENGTH_SHORT).show();
finish();
}
findViewById(R.id.btn_dialog).setOnClickListener(v -> {
//仅模糊背景
BlurDialog dialog = new BlurDialog(v.getContext(), BlurDialog.BLUR_TYPE_BLUR_BACKGROUND);
dialog.show();
});
findViewById(R.id.btn_dialog2).setOnClickListener(v -> {
//仅模糊后方屏幕
BlurDialog dialog = new BlurDialog(this, BlurDialog.BLUR_TYPE_BLUR_BEHIND);
dialog.show();
});
findViewById(R.id.btn_dialog3).setOnClickListener(v -> {
//模糊背景和后方屏幕
BlurDialog dialog = new BlurDialog(this, BlurDialog.BLUR_TYPE_BLUR_BACKGROUND_AND_BEHIND);
dialog.show();
});
Glide.with(this).asDrawable().
load("https://pic2.zhimg.com/v2-febc9228d18886a29c68a66536279dfb_r.jpg?source=1940ef5c")
.addListener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, @Nullable Object model, @NonNull Target<Drawable> target, boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(@NonNull Drawable resource, @NonNull Object model, Target<Drawable> target, @NonNull DataSource dataSource, boolean isFirstResource) {
findViewById(R.id.main).setBackground(resource);
return false;
}
}).submit();
}
/**
* 对话框背景毛玻璃化
*/
private void blurdialog() {
BlurDialog dialog = new BlurDialog(this, BlurDialog.BLUR_TYPE_BLUR_BACKGROUND);
dialog.show();
}
/** @noinspection FieldCanBeLocal*/
public class BlurDialog extends AlertDialog {
private Window mWindow;
//窗口背景高斯模糊程度数值越高越模糊且越消耗性能
private final int mBackgroundBlurRadius = 90;
//窗口周边背景高斯模糊程度
private final int mBlurBehindRadius = 20;
//根据窗口高斯模糊功能是否开启来设置窗口周边暗色的程度
private final float mDimAmountWithBlur = 0f;
private final float mDimAmountNoBlur = 0.4f;
// 根据窗口高斯模糊功能是否开启来为窗口设置不同的不透明度
private final int mWindowBackgroundAlphaWithBlur = 170;
private final int mWindowBackgroundAlphaNoBlur = 255;
//使用一个矩形drawable文件作为窗口背景这个矩形的轮廓和圆角确定了窗口高斯模糊的区域
private Drawable mWindowBackgroundDrawable;
/**
* 高斯模糊的类型
* 0代表只模糊背景
* 1代表之模糊后方屏幕
* 2代表同时模糊背景和后方屏幕
*/
private int mBlurType = 0;
public static final int BLUR_TYPE_BLUR_BACKGROUND = 0;
public static final int BLUR_TYPE_BLUR_BEHIND = 1;
public static final int BLUR_TYPE_BLUR_BACKGROUND_AND_BEHIND = 2;
public BlurDialog(@NonNull Context context, int blurType) {
super(context, R.style.BlurDialogTheme);
mBlurType = blurType;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dialog_blur);
initBlur();
}
private void initBlur() {
mWindow = getWindow();
//替换window默认的背景
mWindowBackgroundDrawable = getContext().getDrawable(R.drawable.window_background);
getWindow().setBackgroundDrawable(mWindowBackgroundDrawable);
//注册一个监听者去监听窗口UI视图是否可见以便调整窗口高斯模糊功能是否开启
setupWindowBlurListener();
//允许背景模糊也可以通过样式属性R.attr#windowBlurBehindEnabled来实现
getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
// 允许背景变暗也可以通过样式属性R.attr#backgroundDimEnabled来实现
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
}
/**
* 设置一个窗口视图状态监听者监听窗口视图是否可见以便是否更新窗口模糊的状态
*/
private void setupWindowBlurListener() {
Consumer<Boolean> windowBlurEnabledListener = this::updateWindowForBlurs;
getWindow().getDecorView().addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
@Override
public void onViewAttachedToWindow(@NonNull View v) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
mWindow.getWindowManager().addCrossWindowBlurEnabledListener(windowBlurEnabledListener);
}
}
@Override
public void onViewDetachedFromWindow(@NonNull View v) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
mWindow.getWindowManager().removeCrossWindowBlurEnabledListener(windowBlurEnabledListener);
}
}
});
}
/**
* 更新窗口的高斯模糊效果
*
* @param blursEnabled
*/
private void updateWindowForBlurs(boolean blursEnabled) {
if (mBlurType == BLUR_TYPE_BLUR_BACKGROUND) {
//仅模糊背景
mWindowBackgroundDrawable.setAlpha(blursEnabled ? mWindowBackgroundAlphaWithBlur : mWindowBackgroundAlphaNoBlur);//调整背景的透明度
getWindow().setDimAmount(blursEnabled ? mDimAmountWithBlur : mDimAmountNoBlur);//调整背景周边昏暗的程度
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
getWindow().setBackgroundBlurRadius(mBackgroundBlurRadius);//设置背景模糊程度
}
return;
}
if (mBlurType == BLUR_TYPE_BLUR_BEHIND) {
//仅模糊后方屏幕
getWindow().setDimAmount(blursEnabled ? mDimAmountWithBlur : mDimAmountNoBlur);//调整背景周边昏暗的程度
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
getWindow().getAttributes().setBlurBehindRadius(mBlurBehindRadius);//设置背景周边模糊程度
}
getWindow().setAttributes(getWindow().getAttributes());//让上面的高斯模糊效果生效
return;
}
//同时模糊背景和后方屏幕
mWindowBackgroundDrawable.setAlpha(blursEnabled ? mWindowBackgroundAlphaWithBlur : mWindowBackgroundAlphaNoBlur);//调整背景的透明度
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
getWindow().setBackgroundBlurRadius(mBackgroundBlurRadius);//设置背景模糊程度
}
getWindow().setDimAmount(blursEnabled ? mDimAmountWithBlur : mDimAmountNoBlur);//调整背景周边昏暗的程度
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
getWindow().getAttributes().setBlurBehindRadius(mBlurBehindRadius);//设置背景周边模糊程度
}
getWindow().setAttributes(getWindow().getAttributes());//让上面的高斯模糊效果生效
}
}
}

View File

@ -0,0 +1,7 @@
<!-- res/animator/popup_enter.xml -->
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="300"/>
</set>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="20dp" />
<solid android:color="#AAAAAA" />
</shape>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
tools:context=".activity.DefPopup">
<Button
android:id="@+id/btn_custom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="自定义Popup"/>
</LinearLayout>

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
tools:context=".activity.Dialog">
<Button
android:id="@+id/btn_dialog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="仅模糊背景" />
<Button
android:id="@+id/btn_dialog2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="仅模糊后方屏幕" />
<Button
android:id="@+id/btn_dialog3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="同时模糊背景和后方屏幕" />
</LinearLayout>

View File

@ -5,21 +5,34 @@
android:id="@+id/main" android:id="@+id/main"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".activity.Toast"> tools:context=".activity.DefToast">
<ImageView <ImageView
android:id="@+id/imageView" android:id="@+id/imageView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:scaleType="fitXY"/> android:scaleType="fitXY"/>
<Button <LinearLayout
android:id="@+id/TopToast" android:layout_width="match_parent"
android:layout_width="wrap_content" android:layout_height="match_parent"
android:layout_height="wrap_content" android:orientation="vertical"
android:text="Top Toast"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent"
android:gravity="center">
<Button
android:id="@+id/TopToast"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="顶部"/>
<Button
android:id="@+id/CenterToast"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:text="原生顶部"/>
</LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/line1" android:id="@+id/line1"

View File

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:cardUseCompatPadding="true"
app:shapeAppearance="@null"
app:cardElevation="0dp"
app:cardBackgroundColor="@android:color/transparent"
app:cardForegroundColor="@android:color/transparent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_margin="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
style="@style/TextAppearance.Material3.TitleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textColor="@color/black"
android:text="提示" />
<TextView
style="@style/TextAppearance.Material3.BodySmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:textColor="@color/black"
android:layout_gravity="center_horizontal"
android:text="这是一个弹窗" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="1dp"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout2">
<Button
style="@style/Widget.Material3.Button.TextButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_weight="1"
android:text="取消"
android:textColor="@android:color/holo_blue_light" />
<Button
style="@style/Widget.Material3.Button.TextButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_weight="1"
android:text="确定"
android:textColor="@android:color/holo_blue_light" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/white"
android:padding="16dp">
<TextView
android:id="@+id/menu_item_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Menu Item 1"
android:paddingBottom="12dp"
android:paddingTop="12dp"
android:textColor="@color/black"
android:textSize="18sp"/>
<TextView
android:id="@+id/menu_item_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Menu Item 2"
android:paddingBottom="12dp"
android:paddingTop="12dp"
android:textColor="@color/black"
android:textSize="18sp"/>
<!-- Add more menu items as needed -->
</LinearLayout>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/popup_menu_item_1"
android:title="Item 1" />
<item
android:id="@+id/popup_menu_item_2"
android:title="Item 2" />
<item
android:id="@+id/popup_menu_item_3"
android:title="Item 3" />
</menu>

View File

@ -12,5 +12,17 @@
<item name="android:windowTranslucentNavigation">true</item> <item name="android:windowTranslucentNavigation">true</item>
<!-- Android 5.0+,设置状态栏全透明透明 --> <!-- Android 5.0+,设置状态栏全透明透明 -->
<item name="android:statusBarColor">@android:color/transparent</item> <item name="android:statusBarColor">@android:color/transparent</item>
</style> </style>
<!--高斯模糊activity-->
<style name="BlurActivityTheme" parent="Theme.MaterialComponents.Dialog">
<item name="android:windowIsTranslucent">true</item>
<!-- 原文链接https://blog.csdn.net/abc6368765/article/details/127657069-->
</style>
<!--高斯模糊Dialog-->
<style name="BlurDialogTheme" parent="Theme.MaterialComponents.Dialog">
<item name="android:windowIsTranslucent">true</item>
<!-- 原文链接https://blog.csdn.net/abc6368765/article/details/127657069-->
</style>
</resources> </resources>