gpt4 book ai didi

android - 自定义 AppCompatButton drawableLeft?

转载 作者:太空宇宙 更新时间:2023-11-03 13:52:03 26 4
gpt4 key购买 nike

如何放置 drawableLeftAppCompatButton 的按钮文本,如下图所示?

AppCompatButton

我已尝试应用 paddingLeft,但文本从 drawable 向右移动。

<android.support.v7.widget.AppCompatButton
android:id="@+id/filterBy"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableLeft="@drawable/ic_btn_filter"
android:paddingLeft="20dp"
android:text="@string/filter_by"
android:textAllCaps="false" />

到目前为止,结果看起来像

enter image description here

布局

   <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/profileHeader"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp">

<android.support.v7.widget.AppCompatButton
android:id="@+id/findFriends"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableLeft="@drawable/ic_btn_search"
android:text="@string/find_friends"
android:textAllCaps="false" />

<android.support.v7.widget.AppCompatButton
android:id="@+id/filterBy"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableLeft="@drawable/ic_btn_filter"
android:text="@string/filter_by"
android:textAllCaps="false" />
</LinearLayout>

以及解释清楚的要求。

Using layout_weight property am adjusting the width of both buttons and what i have to do is, the text should be in center of the button and the drawable should be aligned near left of the text.

有什么建议吗?

最佳答案

使用

 android:drawablePadding=""

关于android - 自定义 AppCompatButton drawableLeft?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34015022/

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