我在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"
/>
此代码生成该显示:
的紫色是的LinearLayout,蓝色是TextView的。正如你所看到的,TextView的顶部低于按钮的底部,底部低于LinearLayout的底部。当我将文本添加到TextView中时,LinearLayout会适当地增加其高度,但由于TextView偏移,我总是会丢失最后一行的底部。
我跑层次浏览器,它给了我这个线框:
足见其垂直上方偏移,但是偏出TextView的底部。同样的线框与LinearLayout中选择看起来像这样:
根据层级体系,浏览器,按钮的上方为0,但是TextView的顶部是在7,我已经试过各种修复,主要是从这个网站挑选出来的:
android:paddingTop="0dp"
android:background="@null"
android:includeFontPadding="false"
这些都不是我的问题。