简体   繁体   English

Android App的背景图片

[英]Background Image for Android App

I am an amateur android programmer and I am trying to stylize my app. 我是一个业余的android程序员,我正在尝试风格化我的应用程序。 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? 我真的不明白@ drawable / background的概念,它是如何工作的,我该怎么办?

Set your picture into res/drawable folder. 将图片设置为res/drawable文件夹。 Then in your Layout file ( layout/main.xml ) high problably for your default project add this image view 然后在您的布局文件( layout/main.xml )中为您的默认项目高度概率添加此图像视图

<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 例如,如果您的图片全称为BEATIFULL_CAR .JPG仅添加BEATIFULL_CAR

  1. Drawable is a resource folder in your Android Project where you can past different data. Drawable是Android项目中的资源文件夹,您可以在其中传递不同的数据。
  2. 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 如果要在Drawable文件夹中使用任何图像作为背景副本/过去它,并在layout_main.xml中使用属性android:background="@drawable/your_image_name"作为

    <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 您可以在此链接上了解有关Drawable的更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM