layout_marginTop=-3dp导致内容被遮挡的问题处理
问题描述:
需要将未读消息提示显示在图片的右上角(高出图片),但是却出现消息提示被遮挡的现象。如下所示:
<RelativeLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:paddingLeft="10dp"android:paddingTop="8.5dp" android:paddingBottom="9dp" android:background="@drawable/tt_list_item_bk" ><ImageViewandroid:id="@+id/contact_portrait"android:layout_width="36dp"android:layout_height="36dp" android:layout_centerVertical="true"android:layout_marginRight="10dp" android:scaleType="centerCrop"android:background="@drawable/new_friends_icon"/> <TextViewandroid:id="@+id/contact_item_title"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerVertical="true"android:layout_toRightOf="@id/contact_portrait"android:textColor="@color/contact_name_color"android:textSize="14sp" android:text="申请与通知"/> <TextViewandroid:id="@+id/message_count_notify"android:layout_width="wrap_content"android:minWidth="18dp"android:layout_height="18dp"android:layout_toRightOf="@id/contact_portrait"android:background="@drawable/tt_message_notify"android:gravity="center"android:layout_marginLeft="-15dp"android:layout_marginTop="-3dp"android:paddingLeft="3dp"android:paddingRight="3dp"android:textColor="#FFFFFF"android:textSize="11sp" /> </RelativeLayout>
问题定位:
pandding设置了RelativeLayout 布局内所有content(包括图片、文字、未读提示等)与RelativeLayout 布局顶部和底部的距离。如下:
android:paddingTop="8.5dp"
android:paddingBottom="9dp"
这个空白距离是不能够显示任何内容的。
设置android:layout_marginTop="-3dp",貌似设置与父布局的顶部的距离,将未读提示往上移动。错误的以为paddingTop的空间能够显示未读提示图标,所以导致未读图标被遮挡的现象。
解决方法:
1、将RelativeLayout内android:paddingTop="8.5dp"删除。
2、在ImageView 内增加 android:layout_marginTop="8.5dp"。
3、在未读提示的TextView内设置 android:layout_marginTop="2dp"。
RelativeLayout设置android:paddingTop将会限定所有子视图与其距离。
RelativeLayout内的子视图可以通过layout_marginTop根据自己的需要分别设置自己与RelativeLayout父视图的距离。互相之间不会影响、干扰。
<RelativeLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:paddingLeft="10dp"android:paddingBottom="9dp" android:background="@drawable/tt_list_item_bk" ><ImageViewandroid:id="@+id/contact_portrait"android:layout_width="36dp"android:layout_height="36dp" android:layout_centerVertical="true"android:layout_marginRight="10dp"android:layout_marginTop="8.5dp" android:scaleType="centerCrop"android:background="@drawable/new_friends_icon"/> <TextViewandroid:id="@+id/contact_item_title"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerVertical="true"android:layout_toRightOf="@id/contact_portrait"android:textColor="@color/contact_name_color"android:textSize="14sp" android:text="申请与通知"/> <TextViewandroid:id="@+id/message_count_notify"android:layout_width="wrap_content"android:minWidth="18dp"android:layout_height="18dp"android:layout_toRightOf="@id/contact_portrait"android:background="@drawable/tt_message_notify"android:gravity="center"android:layout_marginLeft="-15dp"android:layout_marginTop="2dp"android:paddingLeft="3dp"android:paddingRight="3dp"android:textColor="#FFFFFF"android:textSize="11sp" /> </RelativeLayout>
layout_marginTop=-3dp导致内容被遮挡的问题处理相关推荐
- android底部弹出显示不全,Android 解决 NestedScrollView 底部内容被遮挡显示不全
Android 解决 NestedScrollView 底部内容被遮挡显示不全 很早之前就遇到过在使用 NestedScrollView 的时候发现底部的 View 总是显示不全, 看起来像是被底部的 ...
- JasperReport类进行PDF打印导致内容缺失
JasperReport进行PDF打印导致内容缺失 1.工作中遇到JasperReport解析jrxml文件,进行PDF打印,导致数据内容缺失部分. 工作中遇到的问题如下: <!--原配置文件如 ...
- JS中event.target事件委派遇到多重子节点的元素导致子节点遮挡父节点事件的解决方法
1.问题描述 事件委派在重复给多个子节点添加相同方法时或者即时添加子节点时很优秀,但如果子节点中还含有自己的子节点,就会发生遮挡. 2.问题分析 event.target会找到使绑定节点执行该事件的触 ...
- div透明但不导致内容div透明的解决方法
将两个层分开不嵌套即可 #div1{width:300px; height:200px; position:relative: } . nav{ background:black;filter:a ...
- android 沉浸式状态栏导致布局被遮挡,沉浸式状态栏导致华为手机虚拟按钮被遮挡的解决办法...
使用了沉浸式状态栏可以让应用给人浑然天成的感觉,是比较好的用户体验,从android 4.4 版本后才能使用城近视状态栏,具体表现是,4.4上是渐变色,5.0以后是全透明. 效果如下: 效果还是挺好的 ...
- ios手机中输入框直接切换时,闪屏导致input被遮挡
当页面多个输入框,直接从一个输入框点击另一个输入框时,页面会闪动,且input会被键盘遮挡. 解决方案 var isIos=this.isIos(); if(isIos){ FastClick.att ...
- UITableViewCell中cell重用机制导致内容重复的方法
UITableView继承自UIScrollview,是苹果为我们封装好的一个基于scroll的控件.上面主要是一个个的UITableViewCell,可以让UITableViewCell响应一些点击 ...
- layui 数据表格内容过长遮挡_word表格技巧:遇到这三种情况,你会处理么?
编按:工作中,除了文字排版,表格应该是排版中比较麻烦的一类.因为各种文档的格式不同,表格也需要随机应变.因此,在排版的过程中,难免会遇到一些表格问题,今天小编总结了3个表格排版常见问题,快来看看吧,希 ...
- Umbra 3:次世代的遮挡裁剪
原文链接:http://www.gamasutra.com/view/feature/164660/sponsored_feature_next_generation_.php?print=1 来自 ...
- HTML 上标题栏把右标题栏遮挡,如何编辑组件的样式(编辑样式)?
如何编辑组件的样式(编辑样式)?如何设置某一块内容的背景.边框.边距.文字样式? 编辑样式为组件通用功能,即几乎每个组件都是有"编辑样式"这个功能的. 一.如何进入组件的" ...
最新文章
- 算法-----最大子序和(Java 版本)
- 【蓄电池维护】第二弹 看似普通的测试仪表笔暗藏了什么玄机?
- 【codeforces 765F】 Souvenirs
- 数据结构学习笔记(六):二叉树(Binary Tree)
- 裸奔、抽烟、凡尔赛,原来数学家玩得这么野……
- 华为宣布:免费培养8000名开发者! 学习免费!实验免费!考证免费!
- python 图标题上移_Python-Matplotlib将图形标题移动到y轴
- 全排列及相关扩展算法(六)——全排列最蛋疼的算法:邻位对换法
- swift项目 9.3以前版本模拟器运行出错
- CodeForces512C-Pluses everywhere-模拟/数学/排列组合模板
- 项目成功的关键是在投资最少的时候找出错误
- ubuntu 11.10 因为gcc版本过高引起的错误,安装 gcc 4.4(转)
- Xcode在 release 模式下断点调试
- Android源码——Logger日志系统
- H5横竖屏的两种解决方法
- 宏观经济学 马工程教材个人笔记整理
- Falcon(一)——数据集管理和数据处理平台
- 最牛逼的java代码_分享史上java最牛逼,最简短的代码
- 【Tool】常用 GIT 命令参阅
- JS 将对象拆开拼接成 URL
热门文章
- linux下装go环境
- 上海证券综合指数昨天成功击破1000点
- 邮箱登陆不了的解决办法
- python 字符串 1.1 从键盘输入10个英文单词,输出其中以元音字母开头的单词。
- 资产初探:信贷资产流转业务及其与资产证券化的区别
- 从零开始搭建一个前端框架(一)环境准备并完成简单打包
- 计算机组成原理浮点运算方法,计算机组成原理第二章 第11讲 浮点运算方法和浮点运算器.ppt...
- 【Android】@GuardedBy注解
- AT32看门狗WDT使用方法
- Choco使用小记--如何设置choco的默认软件包安装位置