Android Button圖片和文字都居左,且有一點間距android
在作項目時須要button上面的文字和圖片都居左,但網上一直找不到文字居左的方法,不少人說button上的文字沒法居左。但本身瞎搗鼓的時候實現了這個功能,並且發現很容易實現這個功能,不知道爲何以前網上查不到呢?因此在此記錄一下,以防下次忘了,以但願能給你們提供幫助。spa
下面是效果圖:3d
源程序:blog
<Button
android:id="@+id/message"
android:layout_width="200dip"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/message_search" //button左側插入圖片
android:paddingLeft="20dip" //圖片距button左側的距離
android:gravity="center_vertical" //加了這條語句後文字就能夠居左了
android:drawablePadding="10dip" //設置文字和圖片間的距離
android:layout_above="@+id/textView1" //如下三行是button位置的設置
android:layout_alignLeft="@+id/textView11"
android:layout_marginBottom="59dp"
android:text="短信查看" />圖片