2016-08-20 33 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

関連する問題