I am an amateur android programmer and I am trying to stylize my app. I found a picture from the internet, here is the link . I want to set that as my background on the application. I would I do so. I really don't understand the concept of @drawable/background, how does it work, what can I do?
Set your picture into res/drawable
folder. Then in your Layout file ( layout/main.xml
) high problably for your default project add this image view
<ImageView
android:id="@+id/myImageView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:scale_type="center_crop"
android:layout_alignParentTop="true" android:src="@drawable/your_picture_name"/>
BUT DON'T ADD YOUR PICTURE'S FILE EXTENTION. ONLY FILE NAME. FOR EXAMPLE IF YOUR PICTURE FULL NAME BEATIFULL_CAR .JPG
ONLY ADD BEATIFULL_CAR
If you want to use any image as a background copy/past it in the Drawable folder and use the attribute android:background="@drawable/your_image_name"
in your layout_main.xml as
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/your_picture_name" android:gravity="center_vertical|center_horizontal"
Thats it.
Your can know more about Drawable at this Link
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.