您的位置:首页 > 其它

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

2017-03-12 13:53 190 查看


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



我的编码方式

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



你没看错,这次的内容就是这样。下周再看妹子。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  FramLayout 覆盖