开发者

Android: ImageView.ScaleType but for Buttons and/or RadioButtons

开发者 https://www.devze.com 2023-02-21 18:54 出处:网络
I like to use a customized (Radio)Button and I know I can use whatever image for the background with the following code inside the xml:

I like to use a customized (Radio)Button and I know I can use whatever image for the background with the following code inside the xml:

<RadioButton
...
android:button="@drawable/myDrawable"
../>

However: I want to use three radiobuttons, that fill the whole row. But the drawable that I use for the button, doesnt get resized depending on the sreensize, so if the drawable is too big only parts of it will show, and if it is too small, not the whole screen will be filled. If I would use ImageViews I could change the ScaleType like so:

ImageView myImageView = (ImageView) findViewById(R.id.myimageview);
myImageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); 

But there is no such property for other Views, than the imageView. So ho开发者_开发百科w can I accomplish the same for (Radio)Buttons?


You will have to provide images with different sizes (see Supporting Multiple Screens)

0

精彩评论

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

关注公众号