1

背景として画像を含める方法と、アプリケーションのどこにどのように画像を配置するか、Eclipse とすべての開発ツールを使用しています。

main_activity.xml でこれまでに行ったことは次のとおりです。

   <RelativeLayout 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="#C0C0C0"
       tools:context=".MainActivity">
    </RelativeLayout>
4

4 に答える 4

3

画像を res/drawable ディレクトリに配置します

<RelativeLayout 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_imagename"
tools:context=".MainActivity" >

</RelativeLayout>
于 2012-12-26T07:43:41.707 に答える
2

検索するだけで入手できます。

res/drawable画像をフォルダに入れて変更するだけです

android:background="#C0C0C0"

android:background="@drawable/your_image_name" (dont give extension of image)
于 2012-12-26T07:45:02.663 に答える
1

res/drawable フォルダー内に .jpg または .png 画像を配置し、背景属性を次のように変更します。

android:background="@drawable/image-name"

image-name画像の実際の名前はどこにありますか。

ご覧のとおり、drawable-mdpi や drawable-hdpi など、いくつかの描画可能なフォルダーがあります。これらは、画面密度が異なるデバイスの画像を保存するように設計されています。アプリケーションがさまざまなデバイスで適切に表示されるようにするには、密度ごとに代替画像を提供してください。@drawable/image-name属性を変更する必要はありません。Android が適切なドローアブル フォルダーを選択します。お役に立てれば。

于 2012-12-26T07:46:46.970 に答える
1

画像のみを使用.jpgおよび.pngフォーマットできます。その後、画像をコピーresしてアプリケーションのフォルダーに貼り付けます。あなたのイメージの名前がimage.png

このコードを使用してください..

<RelativeLayout 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/image"
tools:context=".MainActivity" >

</RelativeLayout>
于 2012-12-26T07:49:35.527 に答える