https://greenhelix.tistory.com/164
์๋๋ก์ด๋ ๋ชจ๋ ๊ธ์ ๊ฐ์ธ ๊ณต๋ถ, ๊ฐ๋ฐ ๋ชฉ์ ์ด๋ผ ๊ฐ๋
์ ๋ํ ์ค๋ช
์ด ์ ๋๋ก ๋ค์ด๊ฐ์ง ์์ผ๋, ์ฐธ๊ณ ํ์๊ธธ ๋ฐ๋๋๋ค.
View
ํ
์คํธ ๋ทฐ์ text์์ฑ ์ง์ ๋ฐฉ๋ฒ์ 2๊ฐ๊ฐ ์๋ค.
- ๊ทธ๋ฅ text ์์ฑ ์ถ๊ฐ(๋์์ธ์์ ๊ฑด๋๋ ค์)
- strings.xml ํ์ผ ๊ฑด๋๋ฆฌ๋ ๋ฐฉ๋ฒ
์ด๋ฒ์ ์๋ ๋ฐฉ๋ฒ์ผ๋ก ์ค์ตํด๋ณด์.
์๋ ์ฒ๋ผ strings.xmlํ์ผ์ ์ถ๊ฐํด์ค๋ค.
๋ค์ ๋์์ธ์์ text view๋ฅผ ๋ง๋ค์ด ์ฃผ๊ณ , ์์ฑ text์ ๊ฐ์ @string/person_name์ผ๋ก ํด์ฃผ๋ฉด
์ง์ ํ ์ด๋ฆ์ธ "์ดํ์"์ด textView์ ๋ณด์ด๊ฒ ๋๋ค.
์ฐธ๊ณ ๋ก ์๋๋ก์ด๋์์ ๋ค๊ตญ์ด๋ฅผ ์ง์ํจ.
- ๋ฆฌ์์ค์ ๊ณตํต ์ ์ฉ๋๋ ๋ณ๋ ฌ ๋ฆฌ์์ค ๋ก๋ฉ๋ฐฉ์์ ์ฌ์ฉ
- app/res ํด๋ ์์ ๋ ๊ฐ์ ํด๋ ๋ง๋ค ๊ณ strings.xmlํ์ผ์ ๋ฃ์ผ๋ฉด ๋จ.
์ถ์ฒ : ์๋๋ก์ด๋ ์ฑ ๊ฐ๋ฐ ๊ต์ฌ(do it)
์์ ๊ฐ์ด ์ด๋ฆ์ ์ง์ ํด์ ํด์ฃผ๋ฉด ๋จ. (ํ๊ธ ์ง์์ด ๋๋ ํ์ผ์ ๋ง๋ค์ด ๋๊ณ ๊ทธ xmlํ์ผ์์ ํ๊ตญ์ด๋ก ์์ฑํ๋ฉด ๋จ)
textView ์์ฑ
- textColor : ํ
์คํธ ์์ ์ค์
- textSize : ํ
์คํธ ์ฌ์ด์ฆ
- textStyle : ํ
์คํธ ์คํ์ผ ์์ฑ(๋๊ป๊ฒ ๋ฑ..)
- textFace : ํ
์คํธ ํฐํธ(๋ค์ด๋ก๋ ๋ฐ์์ ์ฌ์ฉํ ์๋ ์์)
-maxlines : ํ
์คํธ ๋ทฐ์์ ํ์ํ๋ ๋ฌธ์์ด์ ์ต๋ ์ค ์ ์ง์
์๋์ ๊ฐ์ด ์ฝ๋๋ฅผ ์์ฑํ์๋ค๊ณ ํ๋ฉด 2๋ฒ์งธ textView๊ฐ ์ต๋ 1์ค๊น์ง๋ง ํ์ฉ๋๋ฉฐ ๋๋จธ์ง ๊ธ์๊ฐ ๋ชจ๋ ๋ณด์ด์ง ์๋ ๋ค๋ ๊ฒ์ ํ์ธ ํ ์ ์์.
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/person_name"
android:textColor="#FF0000"
android:textSize="40sp"
android:textStyle="bold"
android:typeface="serif" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="์ด๊ณณ์ ์ฌ์ฉ์ ์ด๋ฆ์ ์
๋ ฅํด๋ณด์. ํ์ค๋ก ํ์๋๋?"
android:textColor="#000000"
android:textSize="40sp"
android:textStyle="bold"
android:typeface="serif" />
button ์์ :)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
tools:context=".MainActivity" >
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="์ ํ"
android:textSize="24sp"
android:textStyle="bold"
/>
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/radioButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="RadioButton" />
<RadioButton
android:id="@+id/radioButton2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="RadioButton" />
</RadioGroup>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
<CheckBox
android:id="@+id/checkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CheckBox" />
</LinearLayout>
</LinearLayout>
tip1) extract string resource
1. res -> values -> strings.xml์๋ค๊ฐ ๋ค์์ ์ถ๊ฐํด์ฃผ๋ ๋ฐฉ๋ฒ
2. ๋
ธ๋ ์ ๊ตฌ ํด๋ฆญ ํ