网友通过本文主要向大家介绍了drawablepadding,android view控件,android中view控件,c#datagridview控件,datagridview控件等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
View控件中android:drawablePadding不起作用的原因探究,
<?xml version="1.0" encoding="UTF-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:orientation="horizontal" > <Button android:id="@+id/button1" android:layout_width="300dp" android:layout_height="300dp" android:drawableTop="@drawable/ic_launcher" android:gravity="center" android:drawablePadding="10dp" android:text="ooooo" /> </LinearLayout
看下效果:
我们看到,这个图片和文本之间的距离还是这么大,肯定不是我们设置的10dp,难道是这个属性不起作用,经过多次试验发现,我们的控件大小设置为wrap_content,这个android:drawablePadding才起作用,现在改了以后看下效果:
现在有效果了,如果控件的大小设置为wrap_content,默认文本和图像的大小为0,如果设置为match_parent或者固定的高度,则图片会尽量往外靠,android:drawablePadding会不起作用,所以大家在使用android:drawablePadding这个属性的时候要注意这个问题!!!