Android RadioButton控件怎么设置图片(属性)?android:?????(drawable)

Android RadioButton控件怎么设置图片(属性)?android:?????(drawable),第1张

我觉得RadioButton原始的button如果设置为 android:button="@null“ 而用android:drowableLeft=”@drawable/radiobtn_selector“;这样显示图片的话效果会更加好,而且可以用android:drawablePading=”10dp“这个属性控制图片和字儿的距离。希望可以帮到你。Thanks

请参考gtk+2.0编程范例1.6,

创建image控件加载图片文件 创建按钮  把image控件add到button里

GtkWidget *image = gtk_image_new_from_file(图片文件名)

GtkWidget *button = gtk_button_new()

gtk_container_add(GTK_CONTAINER(button), image)

记住gtk+里 容器“套”容器 ,“控件”装“控件”

先看看效果图:

Android系统中,RadioButton控件默认的布局方式是背景图在左,文字说明在右。

在具体的项目开发中,有时候需要调整二者之间的相对位置,比如:RadioButton的说明文字在上,RadioButton的背景图片在下。

Android开发中如何改变RadioButton背景图片和文字的相对位置呢?

现在以 RadioButton的说明文字在上,RadioButton的背景图片在下为例进行编码实现。

具体代码的实现:

.....

<RadioButton

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:gravity="center"

android:button="@null"

android:paddingLeft="5dp"

android:textSize="10dip"

android:drawableBottom="@android:drawable/btn_radio"

android:text="@string/_str"/>

<RadioButton

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:gravity="center"

android:button="@null"

android:paddingLeft="5dp"

android:textSize="10dip"

android:drawableBottom="@android:drawable/btn_radio"

android:text="@string/_str"/>

<RadioButton

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:gravity="center"

android:button="@null"

android:textSize="10dip"

android:paddingLeft="1dp"

android:paddingRight="5dp"

android:drawableBottom="@android:drawable/btn_radio"

android:text="@string/_str"/>

.....

代码解释:

android:button="@null"

这句是将RadioButton的背景图屏蔽。

android:drawableBottom="@android:drawable/btn_radio"

此句用意是在原来图标的下边使用系统自带的btn_radio图片做为背景图


欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/bake/11614823.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-17
下一篇2023-05-17

发表评论

登录后才能评论

评论列表(0条)

    保存