Android 沉浸式工具栏把内容挡住
来源:互联网 发布:支付宝小程序源码 编辑:程序博客网 时间:2024/06/05 22:34
我这是参考的ToolBar、大体就是通过marginTop来实现的
有兴趣的同学可以参考ToolBar的源码
直接上代码
package com.common.widget;import android.annotation.TargetApi;import android.content.Context;import android.os.Build;import android.support.v7.widget.TintTypedArray;import android.util.AttributeSet;import android.widget.RelativeLayout;/** * Created by walkingMen on 2016/5/31. */public class SunToolBar extends RelativeLayout { private int mTitleMarginStart; private int mTitleMarginEnd; private int mTitleMarginTop; private int mTitleMarginBottom; public SunToolBar(Context context) { super(context); init(); } public SunToolBar(Context context, AttributeSet attrs) { super(context, attrs); init(); } public SunToolBar(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); final TintTypedArray a = TintTypedArray.obtainStyledAttributes(getContext(), attrs, android.support.v7.appcompat.R.styleable.Toolbar, defStyleAttr, 0); init(a); } @TargetApi(Build.VERSION_CODES.LOLLIPOP) public SunToolBar(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); final TintTypedArray a = TintTypedArray.obtainStyledAttributes(getContext(), attrs, android.support.v7.appcompat.R.styleable.Toolbar, defStyleAttr, 0); init(a); } private void init() { } private void init(TintTypedArray a) { mTitleMarginStart = mTitleMarginEnd = mTitleMarginTop = mTitleMarginBottom = a.getDimensionPixelOffset(android.support.v7.appcompat.R.styleable.Toolbar_titleMargins, 0); final int marginStart = a.getDimensionPixelOffset(android.support.v7.appcompat.R.styleable.Toolbar_titleMarginStart, -1); if (marginStart >= 0) { mTitleMarginStart = marginStart; } final int marginEnd = a.getDimensionPixelOffset(android.support.v7.appcompat.R.styleable.Toolbar_titleMarginEnd, -1); if (marginEnd >= 0) { mTitleMarginEnd = marginEnd; } final int marginTop = a.getDimensionPixelOffset(android.support.v7.appcompat.R.styleable.Toolbar_titleMarginTop, -1); if (marginTop >= 0) { mTitleMarginTop = marginTop; } final int marginBottom = a.getDimensionPixelOffset(android.support.v7.appcompat.R.styleable.Toolbar_titleMarginBottom, -1); if (marginBottom >= 0) { mTitleMarginBottom = marginBottom; } RelativeLayout.LayoutParams layoutParams = (LayoutParams) getLayoutParams(); layoutParams.setMargins(mTitleMarginStart, mTitleMarginTop, mTitleMarginEnd, mTitleMarginBottom); setLayoutParams(layoutParams); }}
1 0
- Android 沉浸式工具栏把内容挡住
- android 沉浸式状态栏 软键盘挡住输入框问题
- ionic 底部把内容挡住
- android全屏/沉浸式状态栏下,各种键盘挡住输入框解决办法
- android全屏/沉浸式状态栏下,各种键盘挡住输入框解决办法
- android全屏/沉浸式状态栏下,各种键盘挡住输入框解决办法
- android全屏/沉浸式状态栏下,各种键盘挡住输入框解决办法
- android全屏/沉浸式状态栏下,各种键盘挡住输入框解决办法
- android全屏/沉浸式状态栏下,各种键盘挡住输入框解决办法
- android全屏/沉浸式状态栏下,各种键盘挡住输入框解决办法
- android全屏/沉浸式状态栏下,各种键盘挡住输入框解决办法
- Android 沉浸式状态栏把布局顶到状态栏上
- Android 沉浸式 完全沉浸
- Android 沉浸式状态栏 导致Toast内容偏移
- [Android] 关于系统工具栏和全屏沉浸模式
- Android 沉浸式全屏
- Android 沉浸式状态栏
- android 沉浸式 状态栏
- 1.6 五分钟学会OpenStack 基础知识
- hive大数据倾斜总结
- android Html5学习代码
- ubuntu下编译protobuf
- 二叉树的四种遍历的递归和非递归的实现
- Android 沉浸式工具栏把内容挡住
- Gradle学习系列之三——读懂Gradle语法
- Linux环境下安装MySQL|Linux下Mysql安装教程
- 1.7三分钟读懂Saas、Paas、IaaS的区别
- 安卓中的事件分发机制源码解析
- 计算机图形学基础(零) 介绍
- Oracle 海量数据处理- 索引的选择
- CentOS6.5虚拟机安装Caffe大致记录
- git clone: error: RPC failed; result=56, HTTP code = 200