2013-01-04 28 views
0

如何在按鈕中添加一些空間?這是我的代碼下面和圖像是URL它們顯示圖像按鈕和文本的按鈕,但圖像顯示按鈕的最左邊我想添加一些像這樣的圖像開始的空間URL is如何在按鈕中添加圖像時在開始時添加空間

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="45dp" 
    android:orientation="horizontal" > 

      <Button android:id="@+id/MyAccountbutton" 
      style="?android:attr/buttonStyleSmall" 
      android:layout_height="25dip" 
       android:layout_width="fill_parent" 
       android:layout_marginRight="35dip" 
       android:layout_marginLeft="35dip" 
      android:drawableLeft="@drawable/Handshake" 
      android:background="@drawable/curvedplanebutton" 
      android:textColor="@drawable/button_text_color" 
      android:layout_marginTop="15dip" 
      android:text="Payments"/> 
      </LinearLayout> 
+0

'的android:layout_width = 「WRAP_CONTENT」','機器人:drawablePadding = 「10dip」'和'的android:paddingLeft = 「10dip」'應該做的伎倆。如果不是那麼只是創建一個自定義佈局視圖圖像和文字.. – user370305

回答

1

加一些android:drawablePadding這樣圖像就會有一定的空間。下面的代碼更改按鈕的代碼:

<Button android:id="@+id/MyAccountbutton" 
      style="?android:attr/buttonStyleSmall" 
      android:layout_height="25dip" 
       android:layout_width="fill_parent" 
       android:layout_marginRight="35dip" 
       android:layout_marginLeft="35dip" 
       android:drawableLeft="@drawable/Handshake" 
      android:drawablePadding="5dp" 
      android:background="@drawable/curvedplanebutton" 
      android:textColor="@drawable/button_text_color" 
      android:layout_marginTop="15dip" 
      android:text="Payments"/> 
+0

thnx是工作什麼文字?文字和圖像之間有很多距離如何減少空間? –

1

添加android:drawablePadding="16dip"android:paddingLeft="16dip"Button

+0

是我工作thnx –

+0

thnx工作是什麼文字?文字和圖像之間有很多距離如何減少空間? –

+0

您應該減少'android:layout_marginRight =「35dip」'和'android:layout_marginLeft =「35dip」'。請投票。 –