android 按钮位置偏移,Android TextView偏移向下

我在LinearLayout中有两个按钮和一个TextView。我的TextView向下偏移,文本不适合框内。你能解释发生了什么吗?我认为它与填充相关,并且我已经阅读了关于TextView填充风险的几个讨论,但是这并不能解释为什么文本在底部被切掉。Android TextView偏移向下

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:orientation="horizontal"

android:background="#800080">

android:text="This"

android:background="@drawable/button_red"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

/>

android:text="That"

android:background="@drawable/button_green"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

/>

android:text="Copious amounts of text that overflows onto several lines on a small screen, causing the TextView to dangle below the buttons. Why it does this I can't imagine. I only hope someone can help me with this."

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:background="#533f93"

/>

此代码生成该显示:

96c4697501f43f96963ff65c60b6f254.png

的紫色是的LinearLayout,蓝色是TextView的。正如你所看到的,TextView的顶部低于按钮的底部,底部低于LinearLayout的底部。当我将文本添加到TextView中时,LinearLayout会适当地增加其高度,但由于TextView偏移,我总是会丢失最后一行的底部。

我跑层次浏览器,它给了我这个线框:

9813625992ba18ecf2b9b35da46e5416.png

足见其垂直上方偏移,但是偏出TextView的底部。同样的线框与LinearLayout中选择看起来像这样:

767354d7c5c503b8538897e0dcb73ef6.png

根据层级体系,浏览器,按钮的上方为0,但是TextView的顶部是在7,我已经试过各种修复,主要是从这个网站挑选出来的:

android:paddingTop="0dp"

android:background="@null"

android:includeFontPadding="false"

这些都不是我的问题。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值