본문 바로가기

프로그래밍/Android

Button 오브젝트

 

기본 레이아웃

<Button

android:id="@+id/button"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Hello, I am a Button"

/>

 

이미지아이콘 추가

android:drawableLeft="@drawable/image"

android:drawableRight,

android:drawableTop,

android:drawableBottom

 

텍스트와 이미지 간격 설정

android:drawablePadding="10dp"

 

 

 

소스상에서의 레이아웃 구성

Drawable icon = Drawable.createFromPath( "/data/icon/image.png" );

icon.setBounds( 0, 0, icon.getIntrinsicWidth(), icon.getIntrinsicHeight() );

 

Button button = new Button( this );

button.setText("Hello, I am a Button" );

button.setCompoundDrawables( icon, null, null, null );

 

> setCompoundDrawables( left, top, right, bottom );

'프로그래밍 > Android' 카테고리의 다른 글

리시버를 통한 sms데이터 가져오기  (0) 2009.11.16
Broadcast/BroadcastReceiver  (0) 2009.11.11
AlarmManger 사용  (0) 2009.11.10
AsyncTask 이해하기  (0) 2009.11.09
테마설정하기  (0) 2009.11.09
타이틀바 없애기  (0) 2009.11.09
상태바 알림 처리  (0) 2009.11.09
Toast View 만들기  (0) 2009.11.09
AlertDialog 만들기  (0) 2009.11.06
Intent 기본사항  (0) 2009.11.04