2013-10-21 53 views
2

我正在使用Google地圖製作應用程序。我正在使用AutoCompleteTextView獲取地點的建議。輸出如下:Android AutoCompleteTextView重疊TextView的建議

enter image description here

正如你可以從圖片看,意見箱的邊界重疊的TextView。我在線性佈局中使用帶Textview的自定義項目佈局。

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="#fff" 
    android:orientation="horizontal" > 

    <TextView 
     android:id="@+id/resultValue" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="#fff" 
     android:paddingBottom="5dp" 
     android:paddingLeft="5dp" 
     android:paddingRight="5dp" 
     android:paddingTop="5dp" 
     android:textColor="#474040" 
     android:textSize="15sp" /> 

</LinearLayout> 

有沒有辦法讓建議窗口關閉,並刪除或更改建議窗口的灰色邊框的顏色?

回答

2

嘗試這樣,機器人:popupBackground = 「#EFEEEC」 根據你的邊界 //改成你想要的意見箱

<AutoCompleteTextView 
      android:id="@+id/autocomplete" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_margin="10dp" 
      android:background="@drawable/text_area" 
      android:inputType="text|textNoSuggestions|textMultiLine" 
      android:paddingLeft="10dp" 
      android:popupBackground="#EFEEEC" 
      android:textColor="#333333" 
      android:textColorHint="#9c9c9c" 
      android:textSize="18sp" 
      android:completionThreshold="1" /> 

和auto_textview.xml

<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:padding="12dp" 
    android:textColor="#333333" 
    android:layout_margin="15dp" 
    android:textSize="16sp" > 
</TextView> 

text_area9.png

enter image description here

最後的輸出會像

enter image description here

希望這有助於你。

+0

是的,它的工作!謝謝 ! –

+0

@ adityap174很樂意爲您效勞。快樂編碼.. –

+0

問題是在eclipse中,popupBackground不會出現在自動填充建議中,所以我錯過了它。你能告訴我如何改變邊框的大小嗎?使用你的方法,我能夠改變顏色,並通過此條目: [鏈接](http://daniel-codes.blogspot.in/2012/11/styling-autocompletetextview.html)我能夠改變分隔線樣式但