TextViewで、文字列の配置を設定する
最終更新日:2015-08-14
      
    TextViewの幅をmatch_parentにしたり、複数行を表示したりするときの配置方法を設定できます。
XMLでは、android:gravityで設定します。
<TextView
    android:text="@string/message"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="right|top"/>
android:gravityには、以下の値を|(or)でつないだものが指定できます。
- left : 左寄せ
 - right : 右寄せ
 - top : 上寄せ
 - bottom : 下寄せ
 - center_horizontal : 水平方向で中央揃え
 - center_vertical : 垂直方向で中央揃え
 
例えば、left|topとすると次のようになります。
right|topとすると次のようになります。



