最終更新:
moonlight_aska 2011年07月23日(土) 22:46:26履歴
ウィジェットは, 自身の中にパディング(Padding)と呼ばれる一定の間隔を設定できる.
パディングは, 設定対象の内側に設定される間隔である.

注) エディットテキスト(EditText)やボタン(Button)など一部のウィジェットは, デフォルトのパディングが設定されている.
そのため, パディングを設定すると予想と異なる見た目となるので, パディングを設定する際は注意が必要である.
パディングは, 設定対象の内側に設定される間隔である.

- res/layout/main.xml
- リニアレイアウト(LinearLayout)のTop及びLeftにパディングを設定する.
- テキストビュー(TextView)のTop/Buttom/Left/Rightにパディングを設定する.
<?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:paddingTop="50.0px"
android:paddingLeft="100.0px"
>
<TextView android:id="@+id/text01_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#FFFF00"
android:textColor="#000000"
android:text="パディングあり"
android:padding="20.0px"
/>
<TextView android:id="@+id/text02_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFF"
android:textColor="#000000"
android:text="パディングなし"
/>
</LinearLayout>
注) エディットテキスト(EditText)やボタン(Button)など一部のウィジェットは, デフォルトのパディングが設定されている.
そのため, パディングを設定すると予想と異なる見た目となるので, パディングを設定する際は注意が必要である.
コメントをかく