Using default Android Icons

The Android platform comes with a lot of default icons. Check this visual index of the android drawables to have an idea of what can be used.

Some examples of using these icons:

For use on an ImageButton, defined in xml:


<ImageButton
android:id="@+id/lock"
android:src="@android:drawable/ic_lock_lock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>

Or the same set in code:


ImageButton btn = (ImageButton)findViewById(R.id.lock);
btn.setImageResource(android.R.drawable.ic_lock_lock);

And another example of using these icons in your menu:


/**
* Creates the menu items
*/
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, MENU_HELP, 0, R.string.help).setIcon(
android.R.drawable.ic_menu_help);
return true;
}

Leave a Reply

Your email address will not be published. Required fields are marked *

Please reload

Please Wait