Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/188.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 缩放作为按钮背景的图像_Android_Image_Button - Fatal编程技术网

Android 缩放作为按钮背景的图像

Android 缩放作为按钮背景的图像,android,image,button,Android,Image,Button,我有一个相当大的按钮,我想设置一个图像作为它的背景。我希望它像是按钮空间的70%,中间有重力。 这样做的“好”方法是使用9面片图像: style="background:url('yourimage') no-repeat; background-size:70%; background-position:50% 50%;" 有一个工具可用于此: 如果您想使用自己的图像,则按钮将自动调整为图像的大小。您是在谈论Android还是web编程?它对我不起作用我想它是java语言的代码我需要一

我有一个相当大的按钮,我想设置一个图像作为它的背景。我希望它像是按钮空间的70%,中间有重力。 这样做的“好”方法是使用9面片图像:

style="background:url('yourimage') no-repeat; background-size:70%; background-position:50% 50%;"

有一个工具可用于此:


如果您想使用自己的图像,则按钮将自动调整为图像的大小。

您是在谈论Android还是web编程?它对我不起作用我想它是java语言的代码我需要一个AdnRoid的代码这是web编程(css样式),我想这个答案是在你在问题中添加细节之前添加的。我有六个按钮互相粘住,所以9-patch对我来说不是一个好的解决方案。我想要70%的按钮空间,因为它看起来像菜单。