java - 有什么办法可以在按下一段时间后在另一个视图之上打开不同的视图
解决方案
要在 android 中创建类似的东西,您可以使用带有自定义布局的 alertDialog 并模糊背景: custom_layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<LinearLayout
android:orientation="horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/button1"
android:layout_below
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
在活动中:
//create an alert builder
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Name"); //you can add this to your custom layout only
// set the custom layout
final View view = getLayoutInflater().inflate(R.layout.custom_layout, null);
builder.setView(view);
Button button1 = (Button) view.findViewById(R.id.button1); // etc.. for button2,3,4.
// onclick functions
// create and show the alert dialog
AlertDialog dialog = builder.create();
dialog.show();
对于模糊背景,您可以添加像https://stackoverflow.com/a/41373144/7364284这样的主题,但是我建议使用像https://stackoverflow.com/a/10381077/7364284这样的窗口属性,因为它的代码较少并且易于使用。
推荐阅读
- javascript - testcafe 等待后端服务启动
- jmeter - 如何在 jmeter 中执行 Robotframework 脚本进行性能测试。
- c++ - OpenGLGL - 如何检查光标是否与对象区域重合?
- path - 在给定的约束下,找到具有最大值和的图(循环)中简单路径的长度
- java - 如何删除域下不同路径的所有cookie
- laravel - 调用未定义的方法 Illuminate\Database\Query\Builder::exchanges()
- javascript - kafka Rest 调用 + D3 动画图表
- angular - 如何以角度解析来自json的数据对象
- php - 仅使用 PHP 限制 HTML 输入中的未来日期
- css - 覆盖默认应用程序图标(SVG 或 Fonticon?)