布局文件 activity_test.xml <?xml version="1.0" encoding="utf-8"?> <Andro
布局文件
activity_test.xml
<?xml version="1.0" encoding="utf-8"?>
<Androidx.constraintlayout.widget.ConstraintLayout xmlns:android="Http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<LinearLayout
android:id="@+id/linearLayout"
android:orientation="vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:background="@color/colorAccent"
android:layout_width="match_parent"
android:layout_height="300dp">
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="100dp"
app:layout_constraintTop_toTopOf="@+id/linearLayout"
app:layout_constraintBottom_toTopOf="@+id/linearLayout"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:alpha="0"
android:background="@android:color/white"
/>
<ImageView
android:id="@+id/image"
android:src="@mipmap/ic_launcher"
app:layout_constraintTop_toTopOf="@+id/linearLayout"
app:layout_constraintBottom_toTopOf="@+id/linearLayout"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="100dp"
android:layout_width="100dp"
android:layout_height="100dp"/>
</androidx.constraintlayout.widget.ConstraintLayout>
MainActivity.java
点击事件
View contentView = LayoutInflater.from(MainActivity.this).inflate(R.layout.activity_test, null);
PopupWindow popWnd = new PopupWindow(MainActivity.this);
popWnd.setContentView(contentView);
popWnd.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
popWnd.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
popWnd.setBackgroundDrawable(new ColorDrawable(0x00000000));
popWnd.setOutsideTouchable(false);
popWnd.setFocusable(true);
//相对于父控件的底部显示 无任何偏移
popWnd.showAtLocation(v, Gravity.BOTTOM, 0, 0);
到此这篇关于Android 实现抖音头像底部弹框效果的文章就介绍到这了,更多相关android 抖音弹框内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!
您可能感兴趣的文章:Android中 TeaScreenPopupWindow多类型筛选弹框功能的实例代码android自定义Dialog弹框和背景阴影显示效果Android 提交或者上传数据时的dialog弹框动画效果Android简单实现自定义弹框(PopupWindow)浅析Android中常见三种弹框在项目中的应用Android填坑系列:在小米系列等机型上放开定位权限后的定位请求弹框示例
--结束END--
本文标题: Android 实现抖音头像底部弹框效果的实例代码
本文链接: https://www.lsjlt.com/news/29875.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-01-21
2023-10-28
2023-10-28
2023-10-27
2023-10-27
2023-10-27
2023-10-27
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0