I'm having this question about setting pictures for Buttons in XML :
I made some .png pictures I want to set as pictures instead of the buttons that I get in default when i create my android apps.. Now I loaded in the files into the drawable folder.. And how do I write in XML to get the right thing?
Is setting the button visible to fal开发者_运维技巧se and adding a picture as background for it an option? Because that's all the ways I thought about. Or is there a better way to do this kind of thing?
what I understood is that you want to set the picture in background. Do it like this in your Button tag:
android:background="@drawable/yourpicturename"
Add the png to the drawable folder that is under the res folder in your project (if you are using eclipse). Then in your XML file simply use android:background="@drawable/filename"
. Make sure to omit the file extension
You can use any of:
drawableTop, drawableLeft, drawableRight, drawableBottom
For example,
<Button android:drawableRight="@drawable/some_image" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Some text" />
The image some_image.png will be positioned to the right of your text in this case.
精彩评论