Home » » Display a drawable graph, using ImageView.

Display a drawable graph, using ImageView.

Written By MR HARI on Minggu, 11 Oktober 2009 | 05.27

If you want to display some simple graphics, you can just draw it to the background of a View, or use ImageView in layout.

Download the graphic android.png and save it in the /res/drawable folder.

- To set background of a View

Add a View in main.xml, and set thr background to "@drawable/android"

<View
android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:background="@drawable/android"
/>


- Using ImageView

Add a ImageView in main.xml

<ImageView
android:id="@+id/myImageView"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

/>

Add the code in onCreate(), after setContentView(R.layout.main)

ImageView MyImageView = (ImageView)findViewById(R.id.myImageView); MyImageView.setImageResource(R.drawable.android);

Both have the same result.
Share this article :

0 komentar:

Posting Komentar

 
Support : Your Link | Your Link | Your Link
Copyright © 2013. Android Center - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger