gpt4 book ai didi

android - 具有一行而不是两行文本的线性布局中按钮的奇怪行为

转载 作者:行者123 更新时间:2023-11-29 01:21:19 25 4
gpt4 key购买 nike

我有一个包裹在 Horizo​​ntalScrollView 中的线性布局。除了布局中的一个按钮高于其余按钮外,一切似乎都运行良好。

这个按钮看起来比其他按钮高的原因是因为它只有一行文本而不是两行。

这是问题的截图:

enter image description here

虽然布局用于键盘服务,但我不认为这是问题所在,因为在 XML 布局文件的设计选项卡中仍然会出现此问题。

这是整个服务的布局代码:

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">

<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="50dp">

<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:id="@+id/tablayout">


<Button
android:layout_width="100dp"
android:layout_height="50dp"
android:text="What did you say?!"
android:id="@+id/T_YouSay"
android:textSize="12sp"
android:textAllCaps="false"/>

<Button
android:layout_width="100dp"
android:layout_height="50dp"
android:text="I identify as a..."
android:id="@+id/T_Identify"
android:textSize="12sp"
android:textAllCaps="false"/>


//This button is the one that is higher then the rest. Notice how
//it is only one line of text instead of two.
<Button
android:layout_width="100dp"
android:layout_height="50dp"
android:text="That's some..."
android:id="@+id/Thats_some"
android:textSize="12sp"
android:textAllCaps="false"/>

<Button
android:layout_width="100dp"
android:layout_height="50dp"
android:text="Here's the thing..."
android:id="@+id/theThing"
android:textSize="12sp"
android:textAllCaps="false"/>

<Button
android:layout_width="100dp"
android:layout_height="50dp"
android:text="Other copypastas"
android:id="@+id/tab_Misc"
android:textSize="12sp"
android:textAllCaps="false"/>


</LinearLayout>

</HorizontalScrollView>

那么,为什么在 Horizo​​ntalScrollView 包裹的 LinearLayout 中,只有一行文本的按钮比其他按钮高,我该怎么做才能解决这个问题?

最佳答案

添加

android:baselineAligned="false"

到包含按钮的 LinearLayout (id == tabLayout)。

关于android - 具有一行而不是两行文本的线性布局中按钮的奇怪行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36658862/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com