2013-03-06 106 views
0

我是一个业余的android程序员,我试图设计我的应用程序。我从网上找到了一张照片,这里是link。我想将其设置为应用程序的背景。我会这样做。我真的不明白@ drawable/background的概念,它是如何工作的,我该怎么办?Android应用程序的背景图像

回答

2

设置你的照片到res/drawable文件夹更多的可绘制。然后在你的布局文件(layout/main.xml)高problably作为默认的项目添加此图像视图

<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"/> 

但切勿将您的图片的文件扩展。只有文件名。对于 示例如果您的图片全名BEATIFULL_CAR .JPG只能添加 BEATIFULL_CAR

+0

我看到多个可绘制文件夹。一个位于res和bin> res – user1842633 2013-03-06 18:33:50

+0

@ user1842633使用** res/drawable ** – hakiko 2013-03-06 18:35:34

+0

我试图添加文件,但它给了我这个:[2013-03-06 14:24:03 - MyApp] res \ drawable-hdpi \ NWHS_JAG.png:无效的文件名:只能包含[a-z0-9_。] – user1842633 2013-03-06 19:27:01

0
  1. Drawable是Android项目中的资源文件夹,您可以在其中通过不同的数据。
  2. 如果你想在绘制对象文件夹中使用任何图像作为背景复制/粘贴,并 使用属性android:background="@drawable/your_image_name"在layout_main.xml 作为

    <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"

完蛋了。

你可知道在这个Link