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. 编程能力如何突飞猛进?
  2. 注释可以出现在c语言任何位置,在c程序中,注释语句只能位于一条语句的后面吗...
  3. nltk 中的 sents 和 words
  4. 实验五:编写、调试具有多个段的程序
  5. python大漠插件多开_[求助,]用python调用大漠插件,注册好后调用出错.完全不会了...
  6. 载winpcap4.1.1_搞不清电力电缆载流量?有这一份最新汇总就够了~
  7. 简单的解决达梦数据库查询 dm.jdbc.driver.DmdbNClob@1064bb3e 问题
  8. ad15的stc元件库_STC8系列 STC15系列STCMCU Protel_Altium原理图PCB器件封装库文件
  9. 用calibre自制图文并茂且支持kindle的mobi电子书
  10. golang程序员前景怎么样?Python、Java、go语言的优势互比
  11. 自动驾驶技术发展的5个阶段和现状
  12. 基于程序员职业对于婚配问题的研究——程序员为何单身?
  13. Python数据分析项目-微信好友数据分析
  14. 帝国插件自动采集文章主动推送给搜索引擎自动安装目录
  15. CC00229.CloudKubernetes——|KuberNetes细粒度权限控制.V13|——|Ratel.v01|k8s资源管理平台部署|
  16. grad-cam一直无法画比较合适的图的原因
  17. sa-token使用
  18. iCloud__Redmine(云服务器安装redmine)
  19. Java + OpenCV 实现图片修复(去水印)(JavaCV)
  20. The 2021 ICPC Asia Shanghai Regional Programming Contest D、E

热门文章

  1. MD5碰撞与撞库和题
  2. 极客时间-算法训练营1.2 实战题目解析:移动零
  3. xp安装winPython的解决方案
  4. 【强化学习论文解读 1】 NAF
  5. Inno Setup 系列之操作ini文件
  6. 论文中文翻译——SketchyCOCO Image Generation from Freehand Scene Sketches
  7. mpf7_CBOE VIX Volatility derivatives_SP 500 Index_near_next option_Why log return_Kurtosis_Skew_OLS
  8. VMWare 虚拟机如何扩展磁盘空间并挂载到已存在的根目录
  9. AS--Unknown Device(Device support,but APK only supports armeabi-v7a)
  10. 2022爱分析·IT运维厂商全景报告 | 厂商征集