songining
article thumbnail

TextView ์‚ฌ์šฉ๋ฒ•

 

 <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="My first application!"
        android:textColor="#D384E1"
        android:textSize="25sp" />

 

1,2.

<wrap_content์™€ march_parent์˜ ์ฐจ์ด์ > ๋ ˆ์ด์•„์›ƒ์ด ๊ฐ์‹ธ๋Š” ์ •๋„๋ฅผ ์ •๋„๋ฅผ ๊ฒฐ์ •ํ• ๋•Œ

-wrap_content: ํ…์ŠคํŠธ๋ฅผ ์ž…๋ ฅํ•˜๋Š”๋ฐ์— ํ•„์š”ํ•œ ๊ธธ์ด๋งŒํผ๋งŒ์„ ๊ฐ์‹ผ๋‹ค. 

-match_parent: ๋ถ€๋ชจ๊ฐ€ ๊ฐ€์ง€๋Š” ํฌ๊ธฐ๋งŒํผ์„ ๊ฐ์‹ผ๋‹ค. (ํ•ด๋‹น ๋ ˆ์ด์•„์›ƒ์˜ ์ปจํ…Œ์ด๋„ˆ  ํฌ๊ธฐ๋งŒํผ์„ ๊ฐ€๋“ ์ฑ„์šด๋‹ค)

 

3.๋ ˆ์ด์•„์›ƒ์•ˆ์˜ ํ…์ŠคํŠธ๋Š” My first application!์œผ๋กœ ์ ์–ด์ฃผ์—ˆ๋‹ค. 

4.ํ…์ŠคํŠธ ์ปฌ๋Ÿฌ๋Š” ๋ณด๋ผ์ƒ‰์œผ๋กœ ํ•ด์ฃผ์—ˆ๊ณ  ๋”ฐ์˜ดํ‘œ์•ˆ์— #ffffff๋ฅผ ์ ์–ด์ฃผ๋ฉด ์ƒ‰์ƒ์„ ํƒํŒ์ด ๋œจ๊ฒŒ๋œ๋‹ค. ๊ทธ ์ƒ‰์ƒํŒ์—์„œ ์›ํ•˜๋Š” ์ƒ‰๊น”์„ ์„ ํƒํ•ด์ฃผ๋ฉด ์ž๋™์œผ๋กœ ๋ฐ”๋€Œ๊ฒŒ ๋œ๋‹ค. 

5.๊ธ€์ž์˜ ํฌ๊ธฐ๋Š” 25sp๋กœ ํ•ด์ฃผ์—ˆ๋‹ค. ํ…์ŠคํŠธ ํฌ๊ธฐ ๋‹จ์œ„๋Š” sp๋กœ ํ•œ๋‹ค. 

 

  <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="2020 07 13 2:59"
        android:textSize="20sp" />

 

EditText ์‚ฌ์šฉ๋ฒ•

 

<EditText
        android:id="@+id/et_id"
        android:layout_width="175dp"
        android:layout_height="wrap_content"
        android:hint="์•„์ด๋””๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”" />

 

1. ์›ํ•˜๋Š” EditText๋ฅผ ๋งŒ๋“ค๋•Œ ๋™์ ์ธ ์•ก์…˜์„ ํ›„์— ๋งŒ๋“ค์–ด ์ฃผ๊ธฐ ์œ„ํ•ด์„œ๋Š” ํ•ด๋‹น EditText์˜ id๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์–ด์•ผ ํ•œ๋‹ค. 

@+id/๊นŒ์ง€๋Š” ๊ธฐ๋ณธ์ด๋ฉฐ ๊ทธ ํ›„์— ์›ํ•˜๋Š” ์•„์ด๋””๋ฅผ ์ง€์–ด์ค€๋‹ค. ๋‚˜๋Š” ์•Œ์•„๋ณด๊ธฐ ์‰ฝ๊ฒŒ et_id๋กœ ํ•ด์ฃผ์—ˆ๋‹ค. 

 

2. EditText์˜ ๊ฐ€๋กœ๊ธธ์ด๋Š” 175 dp๋กœ ํ•ด์ฃผ์—ˆ๋‹ค. (dp๋Š” ๋ ˆ์ด์•„์›ƒ ์น˜์ˆ˜์ด๋‹ค) 

3. EditText์˜ ์„ธ๋กœ๊ธธ์ด๋Š” wrap_content๋กœ ํ•˜์˜€๋‹ค. 

4. EditText์•ˆ์—๋Š” "์•„์ด๋””๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”" ๊ฐ€ ๋œจ๋„๋ก ํ•ด์ฃผ์—ˆ๋‹ค. 

 

Button ์‚ฌ์šฉ๋ฒ•

 

    <Button
        android:id="@+id/btn_click"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="5sp"
        android:text="@string/click" />

 

1. ํ•ด๋‹น ๋ฒ„ํŠผ์˜ id๋Š” ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ์•Œ์•„๋ณด๊ธฐ ์‰ฝ๊ฒŒ btn_click์œผ๋กœ ํ•ด์ฃผ์—ˆ๋‹ค.

2. ๋ฒ„ํŠผ ๋ ˆ์ด์•„์›ƒ์˜ ๊ฐ€๋กœ๋Š” wrap_content๋กœ ํ•˜์˜€๋‹ค. 

3. ๋ฒ„ํŠผ ๋ ˆ์ด์•„์›ƒ์˜ ์„ธ๋กœ๋„ wrap_content๋กœ ํ•˜์˜€๋‹ค. 

4. ๋ฒ„ํŠผ์ฃผ์œ„์˜ ๊ฐ„๊ฒฉ์€ 5sp๋กœ ํ•ด์ฃผ์—ˆ๋‹ค. 

5. ๋ฒ„ํŠผ์•ˆ์˜ ํ…์ŠคํŠธ๋Š” click์œผ๋กœ ํ•ด์ฃผ์—ˆ๋‹ค. 

 

*์ฐธ๊ณ ๋กœ ๋‚˜๋Š” ์œ„์—์„œ ๋งŒ๋“  EditText(et_id)์˜ ์˜ค๋ฅธ์ชฝ์— ๋ฒ„ํŠผ์„ ๋ถ™์—ฌ์ฃผ๊ณ  ์‹ถ์–ด์„œ ๋”ฐ๋กœ ์•ˆ์— ์ƒˆ๋กœ์šด LinearLayout์„ ๋งŒ๋“ค์–ด horizontal๋กœ ์„ค์ •ํ•ด์ฃผ๊ณ  ๊ทธ ์•ˆ์— ๊ฐ™์ด EditText์™€ Button์„ ๋„ฃ๋Š” ๋ฐฉ์‹์œผ๋กœ ์˜†์— ๋ถ™์˜€๋‹ค.

์ „์ฒด LinearLayout์€ vertical์ด๋‹ค. (์ˆ˜์ง ๋‚˜์—ด) 

 

์œ„์™€ ๊ฐ™์€ํ˜•ํƒœ์˜ EditText์™€ Button์„ ํ•˜๋‚˜ ๋” ๋งŒ๋“ค์–ด์ค€๋‹ค.

  <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <EditText
            android:id="@+id/et_move"
            android:layout_width="175dp"
            android:layout_height="wrap_content"
            android:hint="์ž…๋ ฅํ•ด์ฃผ์„ธ์šฉ" />

        <Button
            android:id="@+id/btn_move"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="move"
            android:textColor="#D61054"/>
        </LinearLayout>

 

ํ•ด๋‹น ์ฝ”๋“œ๊นŒ์ง€ ์ถ”๊ฐ€ํ•ด์ค€๋‹ค. 

 

๊ฒฐ๊ณผ๋ฌผ