如何中心绘制的图像和文字在一个单选按钮? [英] How to center drawable image and text in a RadioButton?

查看:107
本文介绍了如何中心绘制的图像和文字在一个单选按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在单选按钮的中心到中心两个图片和文字。这里是我的code: -

I am trying to center both the image and text in the center of the radio button. Here is my code :-

<RadioButton
        android:id="@+id/button4"
        android:layout_width="150dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_toRightOf="@+id/button5"
        android:background="@drawable/left_button_unselected"
        android:shadowColor="@android:color/black"
        android:drawableTop="@drawable/ic_launcher"
        android:button="@null"
        android:gravity="center"
        android:shadowDx="1.0"
        android:shadowDy="1.0"
        android:shadowRadius="2"
        android:text="Latest"
        android:textColor="@color/offblack"
        android:textStyle="normal" />

不过这样一来,图像在左端,并不管我尝试这样做,图像不进来的中心像下面的形象。请帮忙

However by doing this, the image is at the left end and whatever i try to do, the image does not comes in the centre like in the image below. Please help

推荐答案

我创建了一个简单的依据。检查出来: https://gist.github.com/siyamed/7278413851d3a1d02ffc

I created a simple gist for that. check it out: https://gist.github.com/siyamed/7278413851d3a1d02ffc

这篇关于如何中心绘制的图像和文字在一个单选按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆