2011-12-28 3 views
0

AutoCompleteTextView의 UI를 확장하고 싶습니다. 기능은 훌륭합니다. 필요한 것은 드롭 다운 버튼처럼 보이는 버튼을 오른쪽에 추가하는 것입니다. 안타깝게도 AutoCompleteTextView는 0으로 줄일 수없는 '자연스런'마진을 가지고 있습니다.보기의 UI 확장

이제 어떻게해야합니까? 복용량 내 목표를 보관하려면 onDraw() & onMeasure()를 덮어 씁니다. 쉬운 방법이 있습니까?

답변

0

당신은, FrameLayout에 모두 AutoCompleteTextView 버튼을 넣어 약간 더 큰 FrameLayout을 오른쪽 AutoCompleteTextView에 몇 가지 추가 마진을 추가하고, 부모 오른쪽 버튼을 정렬 할 수있다. 사실,이 두 가지보기는 방해가되지만 사용자에게는 여백이 없으면 다른보기 옆에 나타납니다.
또 다른 옵션으로는 사용자 정의 배경을 (마진이 제거 된 Android 소스에서 가져온 원래의 것)으로 설정할 수 있습니다.

마이너스 마진을 제공 할 수 있음을 기억합니다. 두보기를 모두 LinearLayout에 놓고 단추의 왼쪽 여백을 -5dp으로 설정할 수 있습니다. 그러나 버튼에 대한 사용자 정의 여백없는 배경을 제공해야합니다.

+0

의 오른쪽에있는 버튼을 넣어 RelativeLayout를 사용하면 XML에서 내 문제 ('모양'의 해결책 몇 가지 속성 포함). – Klau3

0

사용자 정의 배경을 설정 AutoCompleteTextView

enter image description here

샘플

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="horizontal" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    > 
    <Button android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:background="@drawable/btn_close_pressed" 
android:layout_alignParentRight="true" 
android:id="@+id/myBtn" 
></Button> 
<AutoCompleteTextView android:id="@+id/myautocomplete" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:completionThreshold="1" 
android:layout_toLeftOf="@+id/myBtn" 
/> 
</RelativeLayout>