我有一个按钮上的文字左侧的绘制,但我希望绘制更接近的文本。所以我需要移动drawable。设置可绘制位置内按钮
我定义的android:drawableLeft但按钮的内容不居中。
这里是我的代码:
<Button
android:id="@+id/addsubject"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_action_add"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"
android:layout_marginTop="20dp"
android:text="@string/addsubject"
android:textColor="@color/white"
android:background="@drawable/custombutton1" />
这是现在的样子:
这里是我怎么想它是:
谢谢!
尝试添加'安卓重力= “中心”'你的XML? – suitianshi 2014-08-29 09:03:24
见https://stackoverflow.com/questions/3634191/how-to-center-icon-and-text-in-a-android-button-with-width-set-to-fill-parent/。 – CoolMind 2018-02-28 09:30:04