android - 为什么按钮在 LinearLayout 中没有相同的基线

标签 android android-linearlayout

这是我的 XML 文件

<LinearLayout
    android:weightSum="3"
    android:layout_width="match_parent"
    android:layout_height="128dp"
    android:orientation="horizontal">

    <Button
        android:id="@+id/button3"
        style="@style/Base.Widget.AppCompat.Button.SoundboardUnlockedButton"
        android:layout_weight="1"
        android:text="Butto1111111111111111111n" />

    <Button
        style="@style/Base.Widget.AppCompat.Button.SoundboardUnlockedButton"
        android:id="@+id/button2"
        android:layout_weight="1"
        android:text="Butt1111111111111111on" />

    <Button
        android:id="@+id/button"
        style="@style/Base.Widget.AppCompat.Button.SoundboardUnlockedButton"
        android:layout_weight="1"
        android:text="Bu111111111111111111tton" />
</LinearLayout>

样式 Base.Widget.AppCompat.Button.SoundboardUnlockedButton

<style name="Base.Widget.AppCompat.Button.SoundboardUnlockedButton">
    <item name="android:layout_width">0dp</item>
    <item name="android:layout_height">128dp</item>
</style>

在这里您可以看到按钮没有相同的基线,我该如何解决这个问题? enter image description here

最佳答案

将其放入您的 LinearLayout 中:

android:gravity="center_vertical"

对齐按钮

关于android - 为什么按钮在 LinearLayout 中没有相同的基线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51703336/

相关文章:

android - Fileobserver 的 onevent 方法触发但我如何在删除任何文件之前获取文件

android - 线性布局 - 只有 RecyclerView 滚动

java - Android - RelativeLayout - 并排按钮

android - 应用程序在后台时的 GeoFence 设备

android - android中Imageview的圆角

java - 将 Android 屏幕一分为二

android - 如何去除 LinearLayout 的烦人的 1px 透明板?

android - 为什么 preferences.getString ("key", "DEFAULT") 总是返回 "DEFAULT"?

java - Android 的 StrictMode - 如何正确使用它,为什么没有它我的应用程序无法运行?

android - 2 年后更新的 Android 应用程序,无法让它出现在商店中