开发者

Android ImageButton without Padding

开发者 https://www.devze.com 2023-03-13 09:15 出处:网络
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.

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

精彩评论

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

关注公众号