使用Bottom Sheet实现底部菜单,初步识别
来源:互联网 发布:看不见的客人影评知乎 编辑:程序博客网 时间:2024/06/06 04:52
MainActivity
public class MainActivity extends AppCompatActivity { Button mShowBottomSheet; RelativeLayout design_bottom_sheet; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //获取到Bottom Sheet对象 View bottomSheet = findViewById(R.id.design_bottom_sheet); final BottomSheetBehavior behavior = BottomSheetBehavior.from(bottomSheet); //默认设置为隐藏 behavior.setState(BottomSheetBehavior.STATE_HIDDEN); mShowBottomSheet = (Button) findViewById(R.id.button); design_bottom_sheet=(RelativeLayout)findViewById(R.id.design_bottom_sheet); mShowBottomSheet.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { showBottomSheet(behavior); } }); design_bottom_sheet.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(MainActivity.this,"111",Toast.LENGTH_SHORT).show(); behavior.setState(BottomSheetBehavior.STATE_HIDDEN); } }); } private void showBottomSheet(BottomSheetBehavior behavior) { if (behavior.getState() == BottomSheetBehavior.STATE_HIDDEN) { behavior.setState(BottomSheetBehavior.STATE_COLLAPSED); mShowBottomSheet.setText("hide_bottom_sheet"); } else { behavior.setState(BottomSheetBehavior.STATE_HIDDEN); mShowBottomSheet.setText("show_bottom_sheet"); } }}
<?xml version="1.0" encoding="utf-8"?><android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:paddingBottom="10dp" android:paddingLeft="10dp" android:paddingRight="10dp" android:paddingTop="10dp"> <Button android:id="@+id/button" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:text="Show Bottom Sheet"/> <Button android:id="@+id/fragmentbutton" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:text="Show Bottom Sheet Model"/> </LinearLayout> <RelativeLayout android:id="@+id/design_bottom_sheet" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/colorAccent" android:paddingBottom="10dp" android:paddingLeft="10dp" android:paddingRight="10dp" android:paddingTop="10dp" app:behavior_hideable="true" app:behavior_peekHeight="100dp" app:elevation="4dp" app:layout_behavior="@string/bottom_sheet_behavior"> <TextView android:id="@+id/tv1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="feng" android:layout_marginTop="30dp" /> </RelativeLayout></android.support.design.widget.CoordinatorLayout>
阅读全文
0 0
- 使用Bottom Sheet实现底部菜单,初步识别
- 使用Bottom Sheet实现底部菜单
- Bottom Sheet使用教程
- 使用Bottom Navigation Activity实现Android底部导航栏
- Bottom Sheet
- Android Bottom Sheet属性和使用详解
- Android底部菜单,使用fragment实现
- 使用Fragment实现底部菜单的切换
- Bottom Sheets实现底部动作条
- Android底部bottom的渐变实现
- 微信小程序例子——使用action-sheet弹出小程序底部菜单
- 底部导航Bottom navigation的简单使用
- 实现底部弹出菜单
- android底部菜单实现
- TabHost实现底部菜单
- 底部滑动菜单实现
- Html5-底部菜单实现
- Bottom Sheet的使用和BottomSheetDialogFragment的封装
- Spring Autowired(required = false) 说明
- 【总结】微信小程序
- 强大的矩阵奇异值分解(SVD)及其应用
- 手机端页面制作
- 莱茵棋牌架设所需要工具和软件
- 使用Bottom Sheet实现底部菜单,初步识别
- Codeforces 842 D Vitya and Strange Lesson 线段树
- unbutu16.04 编译 kodi 17.1
- Android 通过appt.exe获取已安装apk的版本信息
- MySQL数据文件说明
- born to do
- 详述 IntelliJ IDEA 提交代码前的 Code Analysis 机制
- python selenium-webdriver 处理JS弹出对话框
- codefores 538-C. Tourist's Notes(数学)