2011-12-19 73 views
1

有沒有在Android的谷歌搜索的代碼? xml佈局對我來說已經足夠了。或者也許有可能在EditText的右側添加一個按鈕,就像在角落中添加一個圖標一樣?謝謝。 enter image description hereAndroid EditText像谷歌搜索EditText

+1

你可以看到[我的答案**這裏**](http://stackoverflow.com/a/11093987/1050058)。將圖標更改爲右側很容易。先試試自己。我稍後會在右邊添加另一個代碼段圖標 – 2013-04-05 01:37:18

回答

1

你有一個水平方向的LinearLayout,你可以有一個EditText,一個帶有搜索圖像的ImageView和一個用於麥克風圖像的ImageView。他們都應該有這樣的方式切割所需的背景圖像,以便看起來像一個。這是一般概念。

關於源代碼,我幫不了你!

希望這會有所幫助!

+0

管理它嗎?需要幫助嗎? – 2011-12-19 15:26:59

2
<LinearLayout 
     android:id="@+id/mainLayout" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="@drawable/bar"//set back ground for total look 
     android:orientation="horizontal" >    
     <EditText 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:hint="Your hint" 
      android:drawableRight="@drawable/search"//give your search icon 
      android:id="@+id/editBox" 
         />    
     <Button     
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/imageSpeak" 
      android:background="@drawable/iconSpeak"//icon for speak 
      /> 


</LinearLayout>