【发布时间】:2015-12-25 10:03:45
【问题描述】:
我正在尝试为按钮添加背景图片,它正在工作,但与我预期的不同。
1st picture (without background)
我希望背景只覆盖按钮。换句话说,图像应该与上面的 2 个按钮具有相同的形式(我说的是圆角和小一点的尺寸)。
这是布局的xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:showIn="@layout/activity_main" tools:context=".MainActivity"
android:orientation="vertical">
<LinearLayout android:layout_weight="1" android:layout_height="fill_parent" android:layout_width="fill_parent">
<Button
android:onClick="playerStats"
android:text="@string/plStats"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
<LinearLayout android:layout_weight="1" android:layout_height="fill_parent" android:layout_width="fill_parent">
<Button
android:text="@string/comp"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
<LinearLayout android:layout_weight="1" android:layout_height="fill_parent" android:layout_width="fill_parent">
<Button
android:background="@drawable/calendar"
android:text="@string/calendar"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
【问题讨论】:
-
你试过用
scaletype
标签: android button layout background-image android-linearlayout