2016-12-03 5 views
2

以前はカスタムスタイルを使用していませんでした。私は私のアプリ上のEditTextのスタイルを、下の画像のように正確にカスタマイズしたいと考えています。Android - EditTextカスタムスタイル

enter image description here

私は私のためにそれを設計するためにあなたを求めていませんよ。ちょうど正しい方向に私を向ける。前もって感謝します!

+0

あなたがこれまでに行ったこと? –

答えて

8

スタイリングにレイヤーリストを使用できます。描画可能なフォルダbg_search.xml

<?xml version="1.0" encoding="utf-8"?> 
     <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
     <item> 
      <shape android:shape="rectangle"> 
      <solid android:color="@android:color/darker_gray" /> 
      <corners android:radius="5dp" /> 
      </shape> 
    </item> 

    <item 
     android:bottom="2dp" 
     android:left="1dp" 
     android:right="1dp"> 
      <shape android:shape="rectangle"> 
      <solid android:color="@android:color/white" /> 
      <corners android:radius="5dp" /> 
      </shape> 
     </item> 
    </layer-list> 

でこのファイルを作成し、EditText

<EditText 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@drawable/bg_search" 
     android:drawableLeft="@android:drawable/ic_menu_search" 
     android:drawablePadding="15dp" 
     android:hint="Search SoundCloud" 
     android:padding="16dp" /> 

出力の背景として適用されます。 enter image description here

+0

ありがとう!これは動作します... – Asym

+0

ハッピーコーディング:) –