随记1——FramLayout先放置Button,再放置TextView,Button会覆盖TextView


女神镇楼

前言:随记系列是记录渣渣在开发过程中遇到的问题和感悟等。

我的编码方式

前几天在“一把梭”的时候,发现一个问题,在FramLayout中先放置一个Button,再放置一个TextView,结果Button把TextView覆盖了。

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <Button
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:textColor="#ffffff"
        android:text="这是一个Button"
        android:textSize="40sp"
        android:background="#00ff00"/>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:textColor="#000000"
        android:text="这是一个TextView"
        android:textSize="40sp"
        android:gravity="center"
        android:background="#ff00ff"/>

</FrameLayout>

显示情况如下:

很明显,理论上TextView应该在Button上层,但是TextView却没有覆盖住Button。原因是啥,我不知道。但是,给Button加上android:enable="false",这时问题就解决了。如下:

你没看错,这次的内容就是这样。下周再看妹子。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值