日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > Android >内容正文

Android

android仿高德地图透明黑字,Android 仿高德地图可拉伸的BottomSheet

發(fā)布時(shí)間:2023/12/1 Android 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android仿高德地图透明黑字,Android 仿高德地图可拉伸的BottomSheet 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

原標(biāo)題:Android 仿高德地圖可拉伸的BottomSheet

2018安卓巴士開發(fā)者大會(huì)-上海站

你一直期待的安卓技術(shù)盛宴即將登場(chǎng)!

前言

最近項(xiàng)目中需要用到高德地圖搜索結(jié)果后的結(jié)果展示的可拉伸控件。

而我看到這個(gè)效果圖,覺得這個(gè)就是一個(gè)slidingpanel,但是翻閱了一些發(fā)現(xiàn)用google自帶的bottomsheet實(shí)現(xiàn)更方便

什么是BottomSheet?

Bottom Sheet是Design Support Library23.2 版本引入的一個(gè)類似于對(duì)話框的控件,可以暫且叫做底部彈出框吧。 Bottom Sheet中的內(nèi)容默認(rèn)是隱藏起來的,只顯示很小一部分,可以通過在代碼中設(shè)置其狀態(tài)或者手勢(shì)操作將其完全展開,或者完全隱藏,或者部分隱藏。對(duì)于Bottom Sheet的描述可以在官網(wǎng)查詢:

xmlns:app="http://schemas.android.com/apk/res-auto"

android:id="@+id/cl_chouti"

android:layout_width="match_parent"

android:layout_height="match_parent">

android:layout_width="match_parent"

android:layout_height="match_parent">

android:id="@+id/map_view"

android:layout_width="match_parent"

android:layout_height="match_parent"/>

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="center">

android:id="@+id/mark"

android:layout_width="30dp"

android:layout_height="30dp"

android:src="@drawable/poi_marker_pressed"/>

android:layout_width="30dp"

android:layout_height="40dp"

android:layout_below="@+id/mark"/>

android:id="@+id/bottom_sheet"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_alignParentBottom="true"

app:behavior_hideable="true"

app:behavior_peekHeight="160dp"

app:layout_behavior="@string/bottom_sheet_behavior">

layout_bottom_sheet.xml

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:background="#ffffff"

android:orientation="vertical">

android:id="@+id/tv_tishi"

android:layout_gravity="center_horizontal"

android:layout_marginTop="40dp"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="附近熱點(diǎn)"

android:textSize="10sp"/>

android:id="@+id/recyclerview"

android:layout_width="match_parent"

android:layout_height="wrap_content"/>

activity中的使用

//底部抽屜欄展示地址

bottomSheet = findViewById(R.id.bottom_sheet);

behavior = BottomSheetBehavior.from(bottomSheet);

behavior.setBottomSheetCallback( newBottomSheetBehavior.BottomSheetCallback() {

@Override

publicvoidonStateChanged(@NonNull View bottomSheet, @BottomSheetBehavior.State intnewState){

String state = "null";

switch(newState) {

case1:

state = "STATE_DRAGGING"; //過渡狀態(tài)此時(shí)用戶正在向上或者向下拖動(dòng)bottom sheet

break;

case2:

state = "STATE_SETTLING"; // 視圖從脫離手指自由滑動(dòng)到最終停下的這一小段時(shí)間

break;

case3:

state = "STATE_EXPANDED"; //處于完全展開的狀態(tài)

break;

case4:

state = "STATE_COLLAPSED"; //默認(rèn)的折疊狀態(tài)

break;

case5:

state = "STATE_HIDDEN"; //下滑動(dòng)完全隱藏 bottom sheet

break;

}

}

@Override

publicvoidonSlide(@NonNull View bottomSheet, floatslideOffset){

// Log.d("BottomSheetDemo", "slideOffset:" + slideOffset);

}

});

注意分析 CoordinatorLayout 是Meterial Design中的一個(gè)新控件,通過behavior用來協(xié)調(diào)其他組件, 實(shí)現(xiàn)聯(lián)動(dòng),因此父布局必須是CoordinatorLayout 。 注意到布局中,RelativeLayout中的app:layout_behavior=”@string/bottom_sheet_behavior”屬性,點(diǎn)進(jìn)去可以看到,這個(gè)屬性實(shí)際上是設(shè)置系統(tǒng)默認(rèn)實(shí)現(xiàn)的BottomSheet的behavior。原則上來說,只要是可以滾動(dòng)的View,在加上了這個(gè)屬性后,都可以作為BottomSheet來使用,建議使用NestedScrollView或者RecyclerView。

源碼地址:https://github.com/lmDai/GDMapOperate.git

如有不正確的地方,歡迎在下方留言以便更正!

責(zé)任編輯:

總結(jié)

以上是生活随笔為你收集整理的android仿高德地图透明黑字,Android 仿高德地图可拉伸的BottomSheet的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。