「Android/UIテキスト」の版間の差分
提供: 初心者エンジニアの簡易メモ
(ページの作成:「==テキスト書き換え== *xmlレイアウト <<nowiki />TextView android:layout_width="match_parent" android:id="@+id/textView1" android:text="...」) |
(→テキスト書き換え) |
||
| 行4: | 行4: | ||
android:id="@+id/textView1" | android:id="@+id/textView1" | ||
android:text="@string/hello" | android:text="@string/hello" | ||
| − | android:layout_height="wrap_content" | + | android:layout_height="wrap_content" /> |
| − | + | ||
*java | *java | ||
TextView textView1 = (TextView)findViewById(R.id.textView1); | TextView textView1 = (TextView)findViewById(R.id.textView1); | ||
2019年3月8日 (金) 19:16時点における版
テキスト書き換え
- xmlレイアウト
<TextView android:layout_width="match_parent"
android:id="@+id/textView1"
android:text="@string/hello"
android:layout_height="wrap_content" />
- java
TextView textView1 = (TextView)findViewById(R.id.textView1);
textView1.setText("テスト");
テキストアウトライン設定
- xml
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#ffffffff"
android:shadowColor="#ff000000"
android:shadowDy="0"
android:shadowDx="0"
android:shadowRadius="4"
android:text="test"/>
改行テキスト
- xml
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="1、\nテストです\n\n2、てすとです"
android:singleLine="false"
/>
¥nでなく\nでなければならない。
中央寄せ
android:gravity="center"
フォントサイズ
android:textSize="18sp"
余白
android:paddingTop="10sp" android:paddingBottom="10sp" android:paddingLeft="10sp" android:paddingRight="10sp"
match_parentとmatch_parent
同じ意味だが、match_parentの方が推奨(android 2.2[API 8]以上)
