协调者布局 实现上下滑动
来源:互联网 发布:linux查看版本命令 编辑:程序博客网 时间:2024/06/11 17:01
activity_main
<?xml version="1.0" encoding="utf-8"?><android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:fitsSystemWindows="true" tools:context="com.tools.ceshi4.MainActivity"> <Button android:id="@+id/bt_1" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="按钮" /> <include layout="@layout/layout_bottom"/></android.support.design.widget.CoordinatorLayout>
layout_bottom
<?xml version="1.0" encoding="utf-8"?><android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/bottom_sheet" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/black" android:orientation="vertical" app:layout_behavior="android.support.design.widget.BottomSheetBehavior"> <LinearLayout android:layout_width="match_parent" android:orientation="vertical" android:layout_height="800dp" android:background="@android:color/holo_red_dark"> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="按钮" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="按钮" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="按钮" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="按钮" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="按钮" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="按钮" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="按钮" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="按钮" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="按钮" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="按钮" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="按钮" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="按钮" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="按钮" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="按钮" /> </LinearLayout></android.support.v4.widget.NestedScrollView>代码
package com.tools.ceshi4;import android.os.Bundle;import android.support.design.widget.BottomSheetBehavior;import android.support.v4.widget.NestedScrollView;import android.support.v7.app.AppCompatActivity;import android.view.View;import android.widget.Button;import butterknife.Bind;import butterknife.ButterKnife;import butterknife.OnClick;public class MainActivity extends AppCompatActivity { @Bind(R.id.bt_1) Button bt1; @Bind(R.id.bottom_sheet) NestedScrollView bottomSheet; private BottomSheetBehavior mBottomSheetBehavior; private View mBottomSheet; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.bind(this); mBottomSheet = findViewById(R.id.bottom_sheet); mBottomSheetBehavior = BottomSheetBehavior.from(mBottomSheet); mBottomSheetBehavior.setPeekHeight(450); mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); } private void collapsed() { mBottomSheetBehavior.setPeekHeight(450); mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); } @OnClick(R.id.bt_1) public void onViewClicked() { collapsed(); }}
阅读全文
0 0
- 协调者布局 实现上下滑动
- CoordinatorLayout,协调者布局
- 协调者布局
- 协调者布局:CoordinatorLayout
- CoordinatorLayout,协调者布局
- android实现上下滑动
- Android实现上下滑动效果
- Android实现上下滑动效果
- 自定义view,实现上下滑动
- WheelView实现上下滑动选择器
- jquery实现上下滑动图片
- CoordinatorLayout协调布局,实现悬浮导航条
- Android 协调者布局 CoordinatorLayout简单认识
- 使用协调者布局CoordinatorLayout 来实现ParallaxHeaderViewPager的效果,超简单
- Android上下菜单双向滑动实现
- 观察者模式实现上下一起滑动
- jquery实现悬浮栏上下滑动点击
- Android实现上下滑动隐藏/显示工具栏
- C++笔记记录贴1
- MFC 中查看失败信息 GetLastError
- Android炫酷的效果
- Linux下启用RNDIS host端与device端
- sleep和wait的区别
- 协调者布局 实现上下滑动
- Eclipse中的SVN操作
- 转发与重定向的区别
- 基于位置的服务——百度地图SDK练习
- First programs
- CSS 选择器常见类型
- DigitalOcean Vpn
- SpringMVC 常用注解 及 其用法 (下)
- jsp中taglib属性