Androidアプリ入門 No.12 Buttonの表示
今風に書き直した記事がありますので、合わせて参照ください。
blog.webarata3.link
Buttonの表示
Buttonの表示は今まで解説したTextView等の属性で十分に可能である。Buttonクリック等のイベント処理は後述する。
以下、Buttonのサンプルを示す。main.xmlを以下のようにする。
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#fff" > <Button android:text="normal" android:textColor="#000" android:textSize="20sp" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <Button android:text="Yellow Button" android:textColor="#f00" android:background="#ff0" android:textSize="20sp" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <Button android:text="Big Button" android:textColor="#000" android:textSize="40sp" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout>