Android App的背景图片

时间:2013-03-06 18:19:46

标签: java android

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

2 个答案:

答案 0 :(得分:2)

将图片设置为res/drawable文件夹。然后在您的布局文件(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"/>

但请勿添加图片的文件。只有文件名。对于  示例如果您的图片全名为BEATIFULL_CAR .JPG仅添加  BEATIFULL_CAR

答案 1 :(得分:0)

  1. Drawable是Android项目中的资源文件夹,您可以在其中传递不同的数据。
  2. 如果您想在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"

  3. 多数民众赞成。

    您可以在此Link

    了解有关Drawable的更多信息
相关问题