当前位置:网站首页>In XML layout, the button is always displayed on the top layer
In XML layout, the button is always displayed on the top layer
2022-06-29 09:57:00 【Maple forest dream】
I encountered a very strange problem when I was writing a project recently , stay Relativelayout in Button Always at the top , Cannot be overridden by other controls , Then I tried Android 5.0 The following versions can be overwritten normally , after many setbacks , At last I found the reason .
The reasons causing :stateListAnimator attribute
Google in Material Design Launched in , Is a very simple way to achieve a smooth transition between visual states . This property can be through android:stateListAnimator Set it up , It can make the control produce different interaction when clicking . about Button, When clicked, there is a shadow effect by default to indicate the pressed state (5.0 It used to be simple discoloration ).
Reference link :android5.0 StateListAnimator
resolvent :
If Button There are already customized selector Style without the need for native post press shadow effects , have access to android:stateListAnimator=”@null” Remove the shadow effect and make Button Can be covered normally
If you want to keep Button And want it to be covered , You should use a separate Linearlayout Yes Button Package , Remember to give Button And left and right sides of the . Although this method does not conform to the specification , But for the sake of demand, we have to do so .
Code example :
<LinearLayout
android:layout_width="match_parent"
android:layout_height="52dp">
<Button
android:id="@+id/btn"
android:layout_width="match_parent"
android:layout_height="42dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:background="@drawable/login_btn_selector"
android:text="@string/app_login"
tools:ignore="UselessParent"
android:textColor="@color/white"
android:textSize="20sp" />
</LinearLayout>
边栏推荐
- 数据库常见面试题(附答案)
- 云管理平台:9大开源云管理平台(CMP)
- Cloud management platform: openstack architecture design and detailed interpretation
- leetcode MYSQL数据库题目178
- c#判断数组是否包含另一个数组的任何项
- 数据可视化:数据可视化四象限,教你正确应用图标
- ImageView图片填充问题
- watch监听和computed计算属性的使用和区别
- Wechat applet implements the data listener watch, including the watch that destroys the watch and sub attributes
- [technology development] development and design of alcohol tester solution
猜你喜欢

A 3D Dual Path U-Net of Cancer Segmentation Based on MRI

float 与 int 相乘产生的令人崩溃的“ 2.3 * 10 = 22 ”

2020-09-29 非商品模板化代码层次 rapidjson库

Cisco ASA、FTD和HyperFlex HX的漏洞分析复现

Segmentation of Head and Neck Tumours Using Modified U-net

Automatic Multi-Organ SegmVentation on Abdominal CT With Dense V-Networks

UE4 animation redirection

IPC(进程间通信)之管道详解

Making of simple addition calculator based on pyqt5 and QT Designer

Install and configure redis in the Linux environment, and set the boot auto start
随机推荐
Visual assist plug-in settings for UE4 vs
Fully Automated Gross Tumor Volume Delineation From PET in Head and Neck Cancer Using Deep Learning
Install and configure redis in the Linux environment, and set the boot auto start
Easyexcl export 1million lines of EXECL report font error solution
leetcode MYSQL数据库题目180
Data visualization: the significance of data visualization
Segmentation of Head and Neck Tumours Using Modified U-net
Deep Learning-based Automated Delineation of Head and Neck Malignant Lesions from PET Images
The 23 most useful elasticsearch search techniques you must know
Wechat applet realizes store function
LeetCode刷题——泰波那契数列
数据治理:数据治理在数据中台下的解决方案
Kicad learning notes - shortcut keys
KiCad学习笔记--快捷键
FreeRTOS(八)——时间管理
监控数据源连接池使用情况
你知道BFD是什么吗?一文详解BFD协议原理及使用场景
gSoap例子——calc
leetcode MYSQL数据库题目177
数据可视化:数据可视化的意义