android中CoordinatorLayout结合TollBar自定义View的使用效果
来源:互联网 发布:c语言 libevent 编辑:程序博客网 时间:2024/04/30 07:10
自定义 view部分找到了 代码设置方法,贴出来 保存
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); ActionBar bar = getSupportActionBar(); bar.setDisplayShowCustomEnabled(true); bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); bar.setCustomView(R.layout.view_toolbar);
<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:id="@+id/CoordinatorLayout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"> <android.support.design.widget.AppBarLayout android:id="@+id/app_bar" android:layout_width="match_parent" android:layout_height="300dp" android:fitsSystemWindows="true" android:theme="@style/ThemeOverlay.AppCompat.Dark"> <!--android:fitsSystemWindows="true" 布局内容不被上拉到状态--> <!--app:contentScrim="?attr/colorPrimary" 标题栏收缩时颜色参照 activity设置的style --> <!--app:expandedTitleMarginStart="20dp" 标题文字在标题栏扩展情况下 的间距, 标题栏默认文字是CoordinatorLayout --> <!-- app:layout_scrollFlags="scroll|exitUntilCollapsed"跟随页面滚动的模式--> <android.support.design.widget.CollapsingToolbarLayout android:id="@+id/toolbar_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" app:contentScrim="?attr/colorPrimary" app:expandedTitleMarginStart="20dp" app:layout_scrollFlags="scroll|exitUntilCollapsed"> <!--app:layout_collapseMode="parallax" 伴随CollapsingToolbarLayout的缩放模式--> <ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="centerCrop" android:src="@drawable/p" app:layout_collapseMode="parallax" app:layout_collapseParallaxMultiplier="0.7" /> <!--android:layout_height="?attr/actionBarSize" 标题栏收缩时高度参照 actionBar的尺寸 app:layout_collapseMode="pin" 伴随CollapsingToolbarLayout的缩放模式 --> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="50dp" app:layout_collapseMode="pin" /> </android.support.design.widget.CollapsingToolbarLayout> </android.support.design.widget.AppBarLayout> <!-- 类似ScrollView 用在CoordinatorLayout的子布局 app:layout_behavior="@string/appbar_scrolling_view_behavior" 绑定根布局--> <android.support.v4.widget.NestedScrollView android:layout_width="match_parent" android:layout_height="match_parent" android:fillViewport="true" android:fitsSystemWindows="true" app:layout_behavior="@string/appbar_scrolling_view_behavior"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="8dp" android:text="@string/textString" android:textSize="20sp" /> </android.support.v4.widget.NestedScrollView> <!-- app:layout_anchor="@id/app_bar" app:layout_anchorGravity="bottom|end" 指定从属关系--> <android.support.design.widget.FloatingActionButton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="16dp" android:src="@android:drawable/btn_star" app:layout_anchor="@id/app_bar" app:layout_anchorGravity="bottom|end" /></android.support.design.widget.CoordinatorLayout>
0 0
- android中CoordinatorLayout结合TollBar自定义View的使用效果
- Android中使用自定义的view实现圆形图片的效果
- CoordinatorLayout实现view的联动效果
- Android中CoordinatorLayout(协调布局)的使用
- Android中自定义View的MeasureSpec使用
- Android中自定义View的MeasureSpec使用
- Android中自定义View的MeasureSpec使用
- Android中自定义View的MeasureSpec使用
- Android中自定义View的MeasureSpec使用
- Android中自定义View的MeasureSpec使用
- Android中自定义View的MeasureSpec使用
- Android中自定义View的MeasureSpec使用
- Android中自定义View的MeasureSpec使用
- android自定义View中onMeasure的使用
- Android中自定义View的MeasureSpec使用
- Android中自定义View的MeasureSpec使用
- Android中自定义View的MeasureSpec使用
- Android中自定义View的MeasureSpec使用
- [LeetCode] Guess Number Higher or Lower
- 取数游戏_纪中1308_dp
- Nginx配置文件nginx.conf中文详解(总结)
- 莫队(支持修改)算法
- 轻松理解MYSQL MVCC 实现机制
- android中CoordinatorLayout结合TollBar自定义View的使用效果
- [ IP forward ] with Android 4.0 don't work
- 开发运维工具组件介绍
- WindowManager$BadTokenException:Unable to add window--token null is not for an application
- Struts2 validation验证失败之后s:select的list返回不了的解决
- 盒子模型
- 用JS改变CSS样式
- python 正则匹配
- 常见设计模式之单例模式(Singleton)