开发者

Android ImageButton without Padding

Currently my imageButtons display an image with a very undesirable padding around them. How do I get rid of the padding and just have the image as the button.

<ImageButton android:src="@drawable/defaultbutton" 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>
<ImageButt开发者_JAVA技巧on android:src="@drawable/defaultbutton2" 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    />            

Secondly, How do I add links to these imagebuttons to open in the browser onClick


Try:

<ImageButton android:background="@drawable/defaultbutton" 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
<ImageButton android:background="@drawable/defaultbutton2" 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" /> 

As for part 2 of your question... open what in your browser? Open a random URL? If so...

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("http://www.google.com"));
startActivity(intent);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜