2016-08-20 4 views
2

삼각형 드롭 다운 화살표가있는 사각형 테두리가있는 스피너를 만들어야합니다. 그런 회 전자를 만드는 방법? 시도했지만 실제 출력은 예상 출력과 다릅니다. 다음은 예상되는 출력입니다.삼각형 드롭 다운 화살표가있는 사각형 상자가있는 스피너를 만드는 방법은 무엇입니까?

enter image description here

는하지만 내 출력은 다음과 같습니다.

enter image description here

어떻게 직사각형 상자 이미지를 드롭 다운에 스피너를 만드는 방법?

다음은 내가 적용한 코드입니다.

 <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="10dp" 
     android:layout_marginRight="10dp" 
     android:layout_marginTop="1dip" 
     android:orientation="vertical" > 
     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="10dp" 
      android:text="Preferred contact method"> 
     </TextView> 
     <Spinner 
      android:id="@+id/account_spinner" 
      android:layout_width="match_parent" 
      android:layout_height="70dp" 
      android:layout_marginTop="2dp" 
      style="@style/Base.Widget.AppCompat.Spinner.Underlined" 
      /> 
     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="10dp" 
      android:text="Telephone"> 
     </TextView> 

     <EditText 
      android:layout_width="match_parent" 
      android:layout_height="30dp" 
      android:inputType="phone" 
      android:ems="10" 
      android:background="@drawable/edittext_border" 
      android:id="@+id/editText" /> 

는 EditText border.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
android:shape="rectangle" > 
<solid android:color="#ffffff" /> 

<stroke 
    android:width="1dp" 
    android:color="#000000" /> 

하지만 어떻게 삼각형 화살표 및 외부 사각형 테두리 회 신청?

미리 감사드립니다.

+0

는이 이미지 사이의 모든 공백을 제거하고 편집 할 수 있습니까? –

답변

1

미리보기에서 스피너에 바인딩 할 데이터를 알 수 없으므로 XML 레이아웃 미리보기에서 렌더링됩니다. 장치 또는 에뮬레이터에서 실행하면 드롭 다운 화살표가있는 일반 회 전자처럼 보입니다.

1

드롭 다운에 대한 기존 배경 이미지의 Android SDK 폴더를 살펴볼 수 있습니다. 예를 들어 {sdk_folder}\platforms\android-{xx}\data\res\drawable-{density}\dropdown_normal_holo_dark.9.png에 있습니다. 소위 9 패치 드로어 블을 정의하고이를 드롭 다운의 스타일에 적용하는 것만으로도 충분합니다.

이는 만드는 방법에 대해 설명합니다 하나의 당김 (도 9 패치가 무엇인지에 대한 설명에 대한 링크가) : https://developer.android.com/studio/write/draw9patch.html