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

    xiaoxiao2021-03-25  75

    女神镇楼

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

    我的编码方式

    前几天在“一把梭”的时候,发现一个问题,在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",这时问题就解决了。如下:

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

    转载请注明原文地址: https://ju.6miu.com/read-33495.html

    最新回复(0)