In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how Android imitates Amap to achieve stretchable BottomSheet related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that everyone after reading this Android how to imitate Amap to achieve stretchable BottomSheet article will have a harvest, let's take a look.
Effect picture:
When I saw this effect picture, I thought it was a slidingpanel, but I flipped through some of it and found that it was more convenient to implement bottomsheet with google.
What is BottomSheet?
Bottom Sheet is a dialog box-like control introduced by the Design Support Library23.2 version, which can be called the bottom pop-up box for the time being. The content in Bottom Sheet is hidden by default, showing only a small part, and can be completely expanded, or completely hidden, or partially hidden, by setting its state or gesture in the code.
How do I use it?
Add dependency
Implemention 'com.android.support:design:25.3.1'
Layout file
Layout_bottom_sheet.xml
Use in activity
/ / address bottomSheet = findViewById (R.id.bottom_sheet); behavior = BottomSheetBehavior.from (bottomSheet) in the bottom drawer bar; behavior.setBottomSheetCallback (new BottomSheetBehavior.BottomSheetCallback () {@ Override public void onStateChanged (@ NonNull View bottomSheet, @ BottomSheetBehavior.State int newState) {String state = "null"; switch (newState) {case 1: state = "STATE_DRAGGING"; / / transition state when the user is dragging bottom sheet break up or down Case 2: state = "STATE_SETTLING"; / / the short period of time when the view slides freely from the finger to the final stop break; case 3: state = "STATE_EXPANDED"; / / in a fully expanded state break; case 4: state = "STATE_COLLAPSED"; / / default folded state break; case 5: state = "STATE_HIDDEN" / / swipe down to completely hide bottom sheet break;}} @ Override public void onSlide (@ NonNull View bottomSheet, float slideOffset) {/ / Log.d ("BottomSheetDemo", "slideOffset:" + slideOffset);}})
Attention analysis
CoordinatorLayout is a new control in Meterial Design, which is used to coordinate other components and achieve linkage through behavior, so the parent layout must be CoordinatorLayout.
Notice the app:layout_behavior= "@ string/bottom_sheet_behavior" attribute in the RelativeLayout, and you can see that this property is actually the behavior that sets the system's default implementation of BottomSheet. In principle, as long as it is scrollable View, after adding this attribute, it can be used as BottomSheet, it is recommended to use NestedScrollView or RecyclerView.
This is the end of the article on "how Android imitates Amap to achieve extensible BottomSheet". Thank you for reading! I believe you all have a certain understanding of "how Android imitates Amap to achieve stretchable BottomSheet". If you want to learn more, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.