
请参考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图片做为背景图
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)