Android 實現(xiàn)抖音頭像底部彈框效果的實例代碼
更新時間:2020年04月21日 15:51:51 作者:迷路國王
這篇文章主要介紹了Android 實現(xiàn)抖音頭像底部彈框效果,本文通過實例代碼給大家介紹的非常詳細,對大家的學(xué)習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
布局文件
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);

到此這篇關(guān)于Android 實現(xiàn)抖音頭像底部彈框效果的文章就介紹到這了,更多相關(guān)android 抖音彈框內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
您可能感興趣的文章:
- Android高德地圖marker自定義彈框窗口
- Android自定義彈框樣式
- Android啟動頁用戶相關(guān)政策彈框的實現(xiàn)代碼
- Android中 TeaScreenPopupWindow多類型篩選彈框功能的實例代碼
- android自定義Dialog彈框和背景陰影顯示效果
- Android 提交或者上傳數(shù)據(jù)時的dialog彈框動畫效果
- Android簡單實現(xiàn)自定義彈框(PopupWindow)
- 淺析Android中常見三種彈框在項目中的應(yīng)用
- Android填坑系列:在小米系列等機型上放開定位權(quán)限后的定位請求彈框示例
- Android自定義彈框Dialog效果
相關(guān)文章
AndroidStudio中重載方法@Override的使用詳解
這篇文章主要介紹了AndroidStudio中重載方法@Override的使用詳解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-04-04
Android使用百度地圖出現(xiàn)閃退及定位時顯示藍屏問題的解決方法
這篇文章主要介紹了Android使用百度地圖出現(xiàn)閃退及定位時顯示藍屏問題的解決方法,需要的朋友可以參考下2018-01-01
okhttp3.4.1+retrofit2.1.0實現(xiàn)離線緩存的示例
本篇文章主要介紹了okhttp3.4.1+retrofit2.1.0實現(xiàn)離線緩存的示例,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-12-12
Android組件TabHost實現(xiàn)頁面中多個選項卡切換效果
這篇文章主要為大家詳細介紹了Android組件TabHost實現(xiàn)頁面中多個選項卡切換效果的相關(guān)資料,感興趣的小伙伴們可以參考一下2016-05-05
Android 使用CoordinatorLayout實現(xiàn)滾動標題欄效果的實例
下面小編就為大家?guī)硪黄狝ndroid 使用CoordinatorLayout實現(xiàn)滾動標題欄效果的實例。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-03-03

