Android 如何使方形按钮和微调器的高度相同?

Android 如何使方形按钮和微调器的高度相同?,android,android-layout,Android,Android Layout,用例: 我想要一个微调器,右边有一个可点击的方形图像按钮,在同一行上,按钮高度与微调器相同 首先,让imagebutton成为正方形是一个问题,我通过阅读以下线程解决了这个问题: 现在,我将它们放在同一行上,并使用图标方形和大小调整,但不完全符合微调器的大小,微调器的9面片(我认为)在其周围创建某种填充,我的图像使用它来设置其高度,因此它看起来像这样: 如果有人能在这里帮助我,我将不胜感激。布局xml如下: <LinearLayout android:layout_weight="1"

用例:

我想要一个微调器,右边有一个可点击的方形图像按钮,在同一行上,按钮高度与微调器相同

首先,让imagebutton成为正方形是一个问题,我通过阅读以下线程解决了这个问题:

现在,我将它们放在同一行上,并使用图标方形和大小调整,但不完全符合微调器的大小,微调器的9面片(我认为)在其周围创建某种填充,我的图像使用它来设置其高度,因此它看起来像这样:

如果有人能在这里帮助我,我将不胜感激。布局xml如下:

<LinearLayout android:layout_weight="1" android:id="@+id/spinnerRow"
                  android:orientation="horizontal"
                  style="@style/horizontalLayout" android:gravity="top"
                  android:layout_height="wrap_content"
                  android:layout_alignParentTop="true" android:paddingTop="5dp">            
        <LinearLayout android:id="@+id/spinLayout" style="@style/spinLayout" android:layout_weight="1">
            <Spinner android:id="@+id/locSelect" android:layout_height="wrap_content"
                     android:layout_width="fill_parent" android:prompt="@string/loc_prompt"></Spinner>
        </LinearLayout>
        <com.karpet.nuba.util.SquareButton
            android:id="@+id/info" android:orientation="horizontal"
            android:gravity="top" android:layout_height="fill_parent"
            android:layout_width="wrap_content" android:layout_weight="0.5">

            <ImageView
                android:id="@+id/info"
                android:src="@drawable/info"
                android:adjustViewBounds="true"
                android:scaleType="centerInside"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"/>
        </com.karpet.nuba.util.SquareButton>
    </LinearLayout>


您是否尝试将它们放在同一布局上,并将高度设置为匹配或填充父项,因为您将两者的重量设置为0dp。然后尝试使用“等待”功能,它可以工作W=填充,h=dp值,方向=水平面。如果高度有问题,在这种情况下,重量无关紧要。