繁体   English   中英

如何在Button内部使用android:drawableLeft填充顶部和底部空间

[英]How to fill top and bottom space using android:drawableLeft inside Button

我正在使用android:drawableLeft来将drawable放在按钮上,但是像这样:

在此处输入图片说明

如何将match height of drawable的高度与Button的高度match height of drawable

如您所见,我space on top and bottom都有space on top and bottom ,但是我want to fill this space用我的facebook图标want to fill this space

看看我在用什么:

<LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:orientation="vertical"
        android:paddingBottom="5dp"
        android:paddingLeft="20dp"
        android:paddingRight="20dp"
        android:paddingTop="5dp" >

        <Button
            android:layout_width="fill_parent"
            android:layout_height="match_parent"
            android:background="@drawable/fb_bg"
            android:text="Login with Facebook"
            android:drawableLeft="@drawable/fb_icon"
            android:layout_marginBottom="5dp"
            android:drawablePadding="0dp"
            android:textColor="@android:color/background_light"
            android:textAppearance="?android:attr/textAppearanceLarge" />

</LinearLayout>

fb_iconfb_bg (两个drawables对象的大小相同40 x 40

删除父级的填充和Button边距

用这个

<LinearLayout
    android:id="@+id/linearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:orientation="vertical"
    android:paddingLeft="20dp"
    android:paddingRight="20dp" >

    <Button
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:background="@drawable/fb_bg"
        android:text="Login with Facebook"
        android:drawableLeft="@drawable/fb_icon"
        android:drawablePadding="0dp"
        android:textColor="@android:color/background_light"
        android:textAppearance="?android:attr/textAppearanceLarge" />

</LinearLayout>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM