Android 具有自定义背景的按钮
我有一些按钮,我声明它们的背景如下:Android 具有自定义背景的按钮,android,android-layout,button,Android,Android Layout,Button,我有一些按钮,我声明它们的背景如下: <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="40dp" android:text="" android:layout_weight="1" android:background="@drawable/backgroundxml" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:text=""
android:layout_weight="1"
android:background="@drawable/backgroundxml"
/>
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/your_drawable"
android:background="@drawable/your_background" />
到
然后我没有笔划和背景中的开始、中心和结束颜色。那么,如何设置可绘制但仍保留背景
谢谢尝试使用ImageButton。大概是这样的:
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:text=""
android:layout_weight="1"
android:background="@drawable/backgroundxml"
/>
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/your_drawable"
android:background="@drawable/your_background" />
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/your_drawable"
android:background="@drawable/your_background" />