随记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",这时问题就解决了。如下:
你没看错,这次的内容就是这样。下周再看妹子。
相关文章推荐
- OPhone/Android的学习(1)—初步知识,TextView,Button,Layout及事件响应
- 08-21 RadioGroup,RadioButton autoLink属性 TextView中ellipsize属性 TextView的属性
- 08-21 RadioGroup,RadioButton autoLink属性 TextView中ellipsize属性 TextView的属性
- 后面的TextView覆盖住前面的Button
- 接入环信sdk后打包出现Error:Error: Unexpected cast to Button: layout tag was TextView [WrongViewCast]
- Error:Error: Unexpected cast to Button: layout tag was TextView [WrongViewCast]
- 自定义控件----继承framLayout --textview与checkBox
- 解决TextView、Button、TabLayout头部等运行出来大写的问题
- Customizing your button or TextView or another view in ANDROID.
- 系出名门Android(5) - 控件(View)之TextView, Button, ImageButton, ImageView, CheckBox, RadioButton, AnalogClock, DigitalClock
- Android Button及TextView动态变换颜色
- Android 用户界面 Button TextView EditView CheckBox RadioGroup ImageView ImageButton
- Android常见控件之TextView、EditView、Button、Menu
- 通过Button改变TextView文字颜色
- Android widget组件(一):Button、 EditText、TextView
- Android常见控件之TextView、EditView、Button、Menu
- Android开发-EditView, Button, TextView的简单使用
- 设置当TextView中的文字超过TextView的容量时,用省略号代替
- Android下Button/TextView/EditText/Menu的使用
- 自定义Dialog,带textview,EditText,Button