ConstraintLayout约束布局,谷歌官方推荐的布局,Android2.3(API9)以后都可以使用此布局,与其他布局相比其可以很好的减少布局的层次,提升性能,结合RelativeLayout,LinearLayout等布局使用可以最大限度的减小界面的复杂度

大多人对这种布局还是比较陌生,熟练后你就会发现他的强大

ConstraintLayout的具体使用这里先不说了,网上有此内容,而且也是很简单的,只要你去用了,多用几次就很容易上手了

这里分享一个在使用ConstraintLayout布局遇到的问题

  • 问题描述

                             

异常现象:如上图界面,图2显示了底部导航栏后会将界面最底下部份遮住,此时布局中就算有ScrollView照样无法滑动显示,就是说此种布局状态下导航栏会将我们的内容遮住部份

正常现象:导航栏显示后会将整体界面上移,这是ScrollView就会有滑动效果了,内容也就不会被遮住

  • 解决思路

1,layout_marginBottom 缺点:强制间距,不能兼容多类型手机

2,使用LinearLayout或RelativeLayout:经验证其他布局不会有此问题,缺点:回到老路了,我们是要使用约束布局

  • 最终解决办法

简单...

在布局文件中加入下面的代码可以规避此问题

app:layout_constraintBottom_toBottomOf="parent"

android:layout_height="0dp" 官方推荐的写法,不再推荐使用match_parent

注意:上面两个属性得同时存在,不然不会生效

  • 布局文件
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"android:layout_width="match_parent"android:layout_height="match_parent"xmlns:zhy="http://schemas.android.com/tools"><includeandroid:id="@+id/ic_title"layout="@layout/activity_title"app:layout_constraintLeft_toLeftOf="parent"app:layout_constraintRight_toRightOf="parent"app:layout_constraintTop_toTopOf="parent" /><android.support.v4.widget.NestedScrollViewandroid:layout_width="match_parent"app:layout_constraintLeft_toLeftOf="parent"app:layout_constraintTop_toBottomOf="@+id/ic_title"app:layout_constraintBottom_toBottomOf="parent"android:layout_height="0dp"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="vertical"><TextViewandroid:id="@+id/tv_tip"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="@dimen/dp_24"android:layout_marginTop="@dimen/dp_10"android:gravity="center"android:text="置顶类型"android:textColor="@color/sub_text_color"android:textSize="14sp"/><RelativeLayoutandroid:id="@+id/rl_over_stick"android:layout_marginTop="13dp"android:layout_width="match_parent"android:clickable="true"android:layout_height="52dp"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerVertical="true"android:layout_marginLeft="24dp"android:text="全局置顶"android:textColor="#000000"android:textSize="16sp"/><CheckBoxandroid:button="@null"android:background="@drawable/checkbox_choose"android:layout_width="24dp"android:layout_height="24dp"android:layout_centerVertical="true"android:layout_alignParentRight="true"android:layout_marginRight="20dp"/></RelativeLayout><RelativeLayoutandroid:id="@+id/rl_class_stick"android:layout_marginTop="13dp"android:layout_width="match_parent"android:clickable="true"android:layout_height="52dp"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerVertical="true"android:layout_marginLeft="24dp"android:text="分类置顶"android:textColor="#000000"android:textSize="16sp"/><CheckBoxandroid:button="@null"android:background="@drawable/checkbox_choose"android:layout_width="24dp"android:layout_height="24dp"android:layout_centerVertical="true"android:layout_alignParentRight="true"android:layout_marginRight="20dp"/></RelativeLayout><RelativeLayoutandroid:id="@+id/rl_board_stick"android:layout_marginTop="13dp"android:layout_width="match_parent"android:clickable="true"android:layout_height="52dp"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerVertical="true"android:layout_marginLeft="24dp"android:text="本板置顶"android:textColor="#000000"android:textSize="16sp"/><CheckBoxandroid:button="@null"android:background="@drawable/checkbox_choose"android:layout_width="24dp"android:layout_height="24dp"android:layout_centerVertical="true"android:layout_alignParentRight="true"android:layout_marginRight="20dp"/></RelativeLayout><RelativeLayoutandroid:id="@+id/rl_valid_date1"android:layout_marginTop="13dp"android:layout_width="match_parent"android:clickable="true"android:layout_height="52dp"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerVertical="true"android:layout_marginLeft="24dp"android:text="有效期"android:textColor="#000000"android:textSize="16sp"/><ImageViewandroid:id="@+id/iv_arrow1"android:layout_width="8dp"android:layout_height="14dp"android:layout_marginEnd="23.7dp"android:layout_alignParentRight="true"android:layout_centerVertical="true"android:src="@drawable/arrow"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginRight="20dp"android:text="请选择有效期"android:layout_centerVertical="true"android:textSize="@dimen/dp_16"android:layout_toLeftOf="@id/iv_arrow1"android:textColor="@color/sub_text_color"/></RelativeLayout><TextViewandroid:layout_width="match_parent"android:layout_height="1dp"android:layout_marginStart="24dp"android:layout_marginEnd="24dp"android:layout_marginTop="10dip"android:background="#0E000000" /><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="@dimen/dp_24"android:layout_marginTop="@dimen/dp_20"android:gravity="center"android:text="亮度"android:textColor="@color/sub_text_color"android:textSize="14sp"/><RelativeLayoutandroid:id="@+id/rl_illume"android:layout_marginTop="13dp"android:layout_width="match_parent"android:clickable="true"android:layout_height="52dp"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerVertical="true"android:layout_marginLeft="24dp"android:text="点亮此贴"android:textColor="#000000"android:textSize="16sp"/><CheckBoxandroid:button="@null"android:background="@drawable/checkbox_choose"android:layout_width="24dp"android:layout_height="24dp"android:layout_centerVertical="true"android:layout_alignParentRight="true"android:layout_marginRight="20dp"/></RelativeLayout><RelativeLayoutandroid:id="@+id/rl_valid_date2"android:layout_marginTop="13dp"android:layout_width="match_parent"android:clickable="true"android:layout_height="52dp"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerVertical="true"android:layout_marginLeft="24dp"android:text="有效期"android:textColor="#000000"android:textSize="16sp"/><ImageViewandroid:id="@+id/iv_arrow2"android:layout_width="8dp"android:layout_height="14dp"android:layout_marginEnd="23.7dp"android:layout_alignParentRight="true"android:layout_centerVertical="true"android:src="@drawable/arrow"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginRight="20dp"android:text="请选择有效期"android:layout_centerVertical="true"android:textSize="@dimen/dp_16"android:layout_toLeftOf="@id/iv_arrow2"android:textColor="@color/sub_text_color"/></RelativeLayout><TextViewandroid:layout_width="match_parent"android:layout_height="1dp"android:layout_marginStart="24dp"android:layout_marginEnd="24dp"android:layout_marginTop="10dip"android:background="#0E000000" /><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="@dimen/dp_24"android:layout_marginTop="@dimen/dp_20"android:gravity="center"android:text="提升帖子"android:textColor="@color/sub_text_color"android:textSize="14sp"/><RelativeLayoutandroid:id="@+id/rl_upper"android:layout_marginTop="13dp"android:layout_width="match_parent"android:clickable="true"android:layout_height="52dp"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerVertical="true"android:layout_marginLeft="24dp"android:text="提升此贴"android:textColor="#000000"android:textSize="16sp"/><CheckBoxandroid:button="@null"android:background="@drawable/checkbox_choose"android:layout_width="24dp"android:layout_height="24dp"android:layout_centerVertical="true"android:layout_alignParentRight="true"android:layout_marginRight="20dp"/></RelativeLayout><RelativeLayoutandroid:id="@+id/rl_valid_date3"android:layout_marginTop="13dp"android:layout_width="match_parent"android:clickable="true"android:layout_height="52dp"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerVertical="true"android:layout_marginLeft="24dp"android:text="有效期"android:textColor="#000000"android:textSize="16sp"/><ImageViewandroid:id="@+id/iv_arrow3"android:layout_width="8dp"android:layout_height="14dp"android:layout_marginEnd="23.7dp"android:layout_alignParentRight="true"android:layout_centerVertical="true"android:src="@drawable/arrow"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginRight="20dp"android:text="请选择有效期"android:layout_centerVertical="true"android:textSize="@dimen/dp_16"android:layout_toLeftOf="@id/iv_arrow3"android:textColor="@color/sub_text_color"/></RelativeLayout></LinearLayout></android.support.v4.widget.NestedScrollView>
</android.support.constraint.ConstraintLayout>

ConstraintLayout布局内容被手机底部导航条遮住问题相关推荐

  1. android导航条高度修改,Android中修改TabLayout底部导航条Indicator长短的方法

    前言 对于Tablayout相信大家都不陌生,在开发中使用的应该很频繁了,但是底部导航条长短是固定死的,需要自己来改动长短,找了半天没找着方法,看了下官方建议,可以通过映射来修改自己想要的长短,其实也 ...

  2. H5移动端div固定到底部实现底部导航条的几种方式

    H5移动端div固定到底部实现底部导航条的几种方式 需求: 需要把导航固定在底部?只能滑动内容,导航菜单固定不动的.效果如下: 这篇文章主要讲解三种实现方案,包括:fixed,absolute,以及c ...

  3. VS 2015 开发Android底部导航条----[实例代码,多图]

    1.废话背景介绍  在Build 2016开发者大会上,微软宣布,Xamarin将被整合进所有版本的Visual Studio之中. 这也就是说,Xamarin将免费提供给所有购买了Visual St ...

  4. android底部导航栏svg,vue开发移动端底部导航条功能

    效果图 src/app.vue 头部导航 内容区域 import Tabbar from 'components/tabbar'; export default { name: 'App', comp ...

  5. 手把手教你制作手机底部导航栏,领导看完都说好

    手把手教你制作手机底部导航栏,领导看完都说好

  6. 手机底部导航栏完整代码

    效果体验:http://hovertree.com/texiao/mobile/5.htm 可以使用手机浏览器查看体验效果. 以下是手机底部导航栏完整代码,HTML文件代码: <!DOCTYPE ...

  7. 自定义底部导航条刘海机型屏幕出现黑色横条遮挡问题,适配ihone x,ihone 11 和12的机型

    自定义底部导航条刘海机型屏幕出现黑色横条遮挡问题,适配ihone x,ihone 11 和12的机型 修改前情况 修改后情况 打开项目文件 app.vueapp.vue1.增加全局参数 globalD ...

  8. Android 获取底部导航条高度

    获取设备底部导航条高度 /*** 获取底部导航条高度*/ private fun getNavigationBarHeight(): Int {if (!isNavigationBarShow()) ...

  9. android开发时华为手机底部导航栏挡住了应用布局

    原因:使用安卓的BottomNavigationView控件开发底部导航栏同时使用了沉浸式状态栏导致华为手机的底部导航栏会盖住我应用的导航栏. 解决:先写一个工具类 import android.co ...

最新文章

  1. 学建筑要学哪些计算机绘图,建筑学专业学CAD买什么书好?
  2. python爬虫入门教程--快速理解HTTP协议(一)
  3. ubuntu 16.04下安装oracle jdk 1.7
  4. MySQL 字符集相关问题
  5. 简单理解机器学习中的L1距离,L2距离,L-Inf距离
  6. 新手如何检查MacBook电池的运行状况
  7. 详细介绍ASP.NET状态保存方法
  8. 冰点文库下载器Fish-v327-0221
  9. [HP NX6320] 安装 windows2003 操作系统 全过程
  10. 提供通达信level2逐笔还原逐笔成交ticks导出提取工具
  11. java a的2次方_java-获取比a大,最接近a的2的次方的数(最小二次幂,位运算)
  12. 概率论 —— 条件数学期望
  13. win10 1050ti anaconda搭建tensorflow-gpu
  14. MYSQL_ 表结构设计和数据类型优化
  15. c语言合法浮点数,c语言中什么是浮点数
  16. 交集♂差集♂并集♂和其他集合的内置方法
  17. java 小球抛物线_vue 2.0 购物车小球抛物线
  18. MySQL 最新版行政区划
  19. Unix/C/C++--数据类型转换、格式化、cpy、精度
  20. 1718 Cos的多项式

热门文章

  1. 如何使用rest client插件发出json参数请求
  2. 世界上到底有多少种编程语言
  3. 吸引女生学计算机,从改变教室风格开始
  4. Java实现客户端与服务器端的通信
  5. 培训该培什么--后续
  6. 粤友钱配资讲解主力洗盘会遵循哪些方法?
  7. 易观郭炜:企业如何理解大数据价值,如何用好大数据?
  8. Could not download xxx.jar的解决办法
  9. 输入一个整数矩阵,计算位于矩阵边缘的元素之和。所谓矩阵边缘的元素,就是第一行和最后一行的元素以及第一列和最后一列的元素。
  10. AD936x 配置软件介绍 下