android 之PopupWindow的使用
16lz
2021-12-04
popup_example.xml:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:padding="10dip" android:layout_width="fill_parent" android:layout_height="wrap_content" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="10dip" android:text="Test Pop-Up" /> </LinearLayout>
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); PopupWindow pw = new PopupWindow( inflater.inflate(R.layout.popup_example, null, false), 100, 100, true); // 下面的代码假定你的根容器 id为 'main' 也就是parent view pw.showAtLocation(this.findViewById(R.id.main), Gravity.CENTER, 0, 0);
更多相关文章
- android:gravity ,和 android:layout_gravity
- Android(安卓)GUI Padding和斜体字的问题
- Android(安卓)autoLink的注意点
- android 跑马灯效果
- Android的设计模式-迭代器模式
- 不借助 Docker Desktop 在Mac上开发容器应用
- Docker —— 简介与镜像用法
- Springboot docker jenkins 自动化部署并上传镜像
- 初学者的docker学习