我创建了一个非常基本的布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button"
android:drawableStart="@drawable/ic_launcher" />
</LinearLayout>
</RelativeLayout>
根据的文档drawableStart http://developer.android.com/reference/android/R.attr.html#drawableStart,
“要绘制到文本开头的可绘制对象。”
然而,当在我的 Android 4.0.4 手机上运行时,我看到的是:
为什么图标和文字之间有这么大的差距?根据这个答案 https://stackoverflow.com/a/8386510/193619,
“使用 Android 4.0(API 级别 14),您可以使用 android:drawableStart 属性将可绘制对象放置在文本的开头。”
但这不是我观察到的行为。为什么该属性不起作用?
开头和结尾有很多误解。
Start and End在布局 xml 中可以替代left and right以匹配布局方向(LTR 或 RTL)。
所以,当文档说:
“要绘制到文本开头的可绘制对象。”
您必须阅读:
“根据布局方向将可绘制对象绘制到视图的开头”
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)