Android-如何在线性布局中使按钮更高?

Android-如何在线性布局中使按钮更高?,android,android-layout,Android,Android Layout,我在相对布局中有一个线性布局,我想让按钮“更高”,以适应线性布局的高度 我尝试添加了填充,正如你在截图中看到的,布局是“更高”,但按钮不是。我试过“填充家长”、“匹配家长”,但没什么不同。如何使按钮在高度上展开 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_widt

我在相对布局中有一个线性布局,我想让按钮“更高”,以适应线性布局的高度

我尝试添加了填充,正如你在截图中看到的,布局是“更高”,但按钮不是。我试过“填充家长”、“匹配家长”,但没什么不同。如何使按钮在高度上展开

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/timerLayout">

<Chronometer
    android:id="@+id/chronometer1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="48dp"
    android:text="@string/chronometer"
    android:textSize="50sp" />

<LinearLayout
    android:id="@+id/buttonLayout"
    android:orientation="horizontal"
    android:paddingLeft="4.0dp"
    android:paddingTop="50.0dp"
    android:paddingRight="4.0dp"
    android:paddingBottom="4.0dp"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true">

    <Button
        android:id="@+id/btnReset"
        android:layout_width="0.0dp"
        android:layout_height="fill_parent"
        android:drawableLeft="@drawable/ic_restore_white_24dp"
        android:drawableStart="@drawable/ic_restore_white_24dp"
        android:text="@string/pause_btn"
        android:layout_weight="1.5" />

    <Button
        android:id="@+id/btnStart"
        android:layout_width="0.0dp"
        android:layout_height="fill_parent"
        android:text="@string/start_btn"
        android:drawableLeft="@android:drawable/ic_media_play"
        android:drawableStart="@android:drawable/ic_media_play"
        android:layout_weight="1.5" />

    <Button
        android:id="@+id/btnSave"
        android:layout_width="0.0dp"
        android:layout_height="fill_parent"
        android:text="@string/save_btn"
        android:drawableLeft="@drawable/ic_save_white_24dp"
        android:drawableStart="@drawable/ic_save_white_24dp"
        android:layout_weight="1.0" />
</LinearLayout>


您的线性布局显示高度:包裹内容 因此,子元素将只占用指定的空间

尝试为linearlayout指定minHeight,或者简单地删除linearlayout,并在按钮中指定“alignparentbottom=true”。
对于最左边的按钮,给出alignparentStart=true

仔细查看您的
xml
布局文件

 <LinearLayout
    android:id="@+id/buttonLayout"
    android:orientation="horizontal"
    android:paddingLeft="4.0dp"

    android:paddingTop="50.0dp" //this guy 

    android:paddingRight="4.0dp"
    android:paddingBottom="4.0dp"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true">


android:paddingTop
LinearLayout
中每个子级顶部的空间,因此如果移除它,按钮将适合。

您看到的额外空间来自线性布局中的填充值,并且您的按钮已经填充了父线性布局。但是您的线性布局指定了以下内容

android:layout_height="wrap_content"
如果要查看高度更大的按钮,请将线性布局的高度值更改为其他值,如:

android:layout_height="300dp"

你能把你活动的整个布局都贴出来吗?