프로그래밍/Android
Button 오브젝트
chance
2009. 11. 6. 00:35
기본 레이아웃
<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 );