ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • EditText Styling 하기(코너 라인드 처리)
    안드로이드/학습&강좌 2011. 8. 6. 01:07


    간단하게 EditText의 모양을 Styling 하는 방법을 소개 하도록 하겠다~.

    매우 간단하게 깔끔하고 색다른  UI 를 제공 할 수 있다. 대부분의 프로그램은 기본적인 안드로이드 UI를 사용한다.

    그게 아무래도 익숙하고 개발하기도 편해서 그렇겠지만 약간만 신경쓰면 이쁜 모양을 꾸밀 수 도 있다.

    화면을 보자.


    가운데가 새로 만들어낸 EditText이다. 코너에 라운드 처리와 테두리 색깔. 위에서 아래로 내려오는 그라데이션 처리 까지~

    깔끔해 보인다. 뒷배경은.. 그냥 똑같은 스타일로 색깔만 다르게 해서 만들어 본것. ㅎㅎ

    간단하다 사용법을 알아 보겠다.

    drawable 폴더에 아무 이름이나 xml을 작성 하자.

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
     <item android:state_pressed="true" android:state_enabled="true">
      <shape>
       <gradient  
        android:startColor="#dce3d1" android:endColor="#ffffff"
        android:angle="270" />
       
       <stroke
        android:width="2dip" android:color="#8f975d"/>
        
       <corners android:radius="5dip"/>
       
       <padding
        android:left="7dip"
        android:right="7dip"
        android:top="7dip"
        android:bottom="7dip" />
      </shape>
     </item>
     <item android:state_focused="true" android:state_enabled="true">
      <shape>
       <gradient  
        android:startColor="#dce3d1" android:endColor="#ffffff"
        android:angle="270" />
       
       <stroke
        android:width="2dip" android:color="#8f975d"/>
        
       <corners android:radius="5dip"/>
       
       <padding
        android:left="7dip"
        android:right="7dip"
        android:top="7dip"
        android:bottom="7dip" />
      </shape>
     </item>
     <item android:state_enabled="false">
      <shape>
       <gradient  
        android:startColor="#bbc2b2" android:endColor="#898b75"
        android:angle="270" />
        
       <corners android:radius="5dip"/>
       
       <padding
        android:left="7dip"
        android:right="7dip"
        android:top="7dip"
        android:bottom="7dip" />
      </shape>
     </item>
     <item android:state_enabled="true">
      <shape>
       <gradient  
        android:startColor="#dce3d1" android:endColor="#ffffff"
        android:angle="270" />
       
       <stroke
        android:width="0.5dip" android:color="#898b75"/>
        
       <corners android:radius="5dip"/>
       
       <padding
        android:left="7dip"
        android:right="7dip"
        android:top="7dip"
        android:bottom="7dip" />
      </shape>
     </item>
    </selector>

    이렇게 작성한뒤 사용할 EditText에서

    background로  지정만 해주면 된다.

    ex...

    <EditText
     android:layout_gravity="center" 
        android:layout_width="200dip"
        android:layout_height="200dip"
        android:background="@drawable/editbox_s"
        />

    간단하므로 소스는 첨부하지 않겠다.~

    댓글

COPYRIGHT 2010 EpoNg. ALL RIGHTS RESERVED.