【发布时间】:2011-12-16 20:20:02
【问题描述】:
我正在创建一个 Android 应用程序,并且我有一个按钮,其背后有一个自定义背景图像。背景图像只是一个矩形,但现在按钮文本似乎没有垂直居中。这是我的按钮 xml:
<Button
android:id="@+id/save_to_list"
android:layout_below="@+id/info_pic"
android:text="SAVE TO LIST"
android:textColor="@android:color/white"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_width="260dp"
android:layout_height="35dp"
android:layout_marginTop="15dp"
android:layout_marginBottom="15dp"></Button>
我在这里设置背景:
ImageView button_bg = (ImageView)findViewById(R.id.button_background);
savetolist_button.setBackgroundDrawable(button_bg.getDrawable());
是否可以在哪里更改按钮内文本的位置?
【问题讨论】: