Android 實(shí)現(xiàn)抖音頭像底部彈框效果的實(shí)例代碼
布局文件
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
點(diǎn)擊事件
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);
//相對(duì)于父控件的底部顯示 無(wú)任何偏移
popWnd.showAtLocation(v, Gravity.BOTTOM, 0, 0);

到此這篇關(guān)于Android 實(shí)現(xiàn)抖音頭像底部彈框效果的文章就介紹到這了,更多相關(guān)android 抖音彈框內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- Android高德地圖marker自定義彈框窗口
- Android自定義彈框樣式
- Android啟動(dòng)頁(yè)用戶(hù)相關(guān)政策彈框的實(shí)現(xiàn)代碼
- Android中 TeaScreenPopupWindow多類(lèi)型篩選彈框功能的實(shí)例代碼
- android自定義Dialog彈框和背景陰影顯示效果
- Android 提交或者上傳數(shù)據(jù)時(shí)的dialog彈框動(dòng)畫(huà)效果
- Android簡(jiǎn)單實(shí)現(xiàn)自定義彈框(PopupWindow)
- 淺析Android中常見(jiàn)三種彈框在項(xiàng)目中的應(yīng)用
- Android填坑系列:在小米系列等機(jī)型上放開(kāi)定位權(quán)限后的定位請(qǐng)求彈框示例
- Android自定義彈框Dialog效果
相關(guān)文章
AndroidStudio中重載方法@Override的使用詳解
這篇文章主要介紹了AndroidStudio中重載方法@Override的使用詳解,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-04-04
android界面布局之實(shí)現(xiàn)文本塊布局效果示例
這篇文章主要介紹了android實(shí)現(xiàn)文本塊布局效果示例,需要的朋友可以參考下2014-04-04
Android使用百度地圖出現(xiàn)閃退及定位時(shí)顯示藍(lán)屏問(wèn)題的解決方法
這篇文章主要介紹了Android使用百度地圖出現(xiàn)閃退及定位時(shí)顯示藍(lán)屏問(wèn)題的解決方法,需要的朋友可以參考下2018-01-01
APK包名修改 請(qǐng)問(wèn)如何修改APK包名
今天,想在android手機(jī)上安裝兩個(gè)相同的應(yīng)用,本以為可以安裝不同版本的,試了幾次,均相互覆蓋了,于是,只能設(shè)法修改apk所對(duì)應(yīng)的包名(package name),需要了解的朋友可以參考下2012-12-12
okhttp3.4.1+retrofit2.1.0實(shí)現(xiàn)離線緩存的示例
本篇文章主要介紹了okhttp3.4.1+retrofit2.1.0實(shí)現(xiàn)離線緩存的示例,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-12-12
Android組件TabHost實(shí)現(xiàn)頁(yè)面中多個(gè)選項(xiàng)卡切換效果
這篇文章主要為大家詳細(xì)介紹了Android組件TabHost實(shí)現(xiàn)頁(yè)面中多個(gè)選項(xiàng)卡切換效果的相關(guān)資料,感興趣的小伙伴們可以參考一下2016-05-05
Android MIUI通知類(lèi)短信權(quán)限的坑
本篇文章主要介紹了Android MIUI通知類(lèi)短信權(quán)限的坑,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-03-03
Android 使用CoordinatorLayout實(shí)現(xiàn)滾動(dòng)標(biāo)題欄效果的實(shí)例
下面小編就為大家?guī)?lái)一篇Android 使用CoordinatorLayout實(shí)現(xiàn)滾動(dòng)標(biāo)題欄效果的實(shí)例。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-03-03

