Ccna final exam - java, php, javascript, ios, cshap all in one. This is a collaboratively edited question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
Tuesday, May 1, 2012
android image button
How can i create a button with no text and an image centered horizontally ? I don't want to use an ImageButton because I want to define a different backgound image
You just use an ImageButton and make the background whatever you want and set the icon as the src.
ReplyDelete<ImageButton
android:id="@+id/ImageButton01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/album_icon"
android:background="@drawable/round_button" />
You can just set the onClick of an ImageView and also set it to be clickable, Or set the drawableBottom property of a regular button.
ReplyDeleteImageView iv = (ImageView)findViewById(R.id.ImageView01);
iv.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
}
});