[์ƒˆ์‹น ์•ˆ๋“œ๋กœ์ด๋“œ-4] UI ํ”„๋กœ๊ทธ๋ž˜๋ฐ์˜ ๊ธฐ๋ณธ์„ ์ดํ•ดํ•˜์ž
๋ฐ˜์‘ํ˜•

 

 

 

์•ˆ๋“œ๋กœ์ด๋“œ๊ฐ€ ํ”„๋ก ํŠธ์—”๋“œ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์ด๋‹ค ๋ณด๋‹ˆ UI๋Š” ๋ฐ˜๋“œ์‹œ ์ œ๊ณตํ•ด์•ผ ํ•จ
UI๋ฅผ ์ œ๊ณตํ•˜๊ธฐ ์œ„ํ•œ ๋งŽ์€ API์™€ ๊ธฐ๋ฒ•๋“ค์ด ์žˆ์Œ

 


 

10๊ฐ• Activity - View ๊ตฌ์กฐ

 


 

ํ™”๋ฉด ๊ตฌ์„ฑ ๋ฐฉ๋ฒ•

 

• ํ™”๋ฉด์„ ์ถœ๋ ฅํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” Activity ๋ผ๊ณ  ํ•˜๋Š” ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“ค์–ด์ค˜์•ผ ํ•จ.
  ๊ทธ๋ฆฌ๊ณ  ๋Ÿฐํƒ€์ž„ ์‹œ์— ์‹คํ–‰๋˜๊ฒŒ๋” ํ•ด์ฃผ์–ด์•ผ ํ•จ
์ด ํด๋ž˜์Šค๋Š” ๊ฐœ๋ฐœ์ž๊ฐ€  ๋งŒ๋“œ๋Š” ํด๋ž˜์Šค(์•กํ‹ฐ๋น„ํ‹ฐ๋ฅผ ์ƒ์†๋ฐ›์•„์„œ ๋งŒ๋“œ๋Š” ํด๋ž˜์Šค)
• Activity ๋Š” ํ™”๋ฉด ์ถœ๋ ฅ ๋Šฅ๋ ฅ์„ ๊ฐ€์ง€๋Š” ์ปดํฌ๋„ŒํŠธ

์ปดํฌ๋„ŒํŠธ๋ž€? (์ด 4๊ฐ€์ง€)
๊ฐœ๋ฐœ์ž๊ฐ€ ๋งŒ๋“  ํด๋ž˜์Šค์ด์ง€๋งŒ, ์•ˆ๋“œ๋กœ์ด๋“œ ์‹œ์Šคํ…œ์— ์˜ํ•ด์„œ ๋Ÿฐํƒ€์ž„์‹œ์— ๊ฐ์ฒด ์ƒ์„ฑ ๋˜์–ด
๋ผ์ดํ”„ ์‚ฌ์ดํด ๊ด€๋ฆฌ๊ฐ€ ๋˜๋Š” ํด๋ž˜์Šค
ex) Activity, Service, ContentProvider, BroadcastReceiver
(๊ฐ๊ฐ ์•กํ‹ฐ๋น„ํ‹ฐ๋ฅผ ์ƒ์†๋ฐ›์•„์„œ ๋งŒ๋“œ๋Š” ํด๋ž˜์Šค, ์„œ๋น„์Šค๋ฅผ ์ƒ์†๋ฐ›์•„์„œ ๋งŒ๋“œ๋Š” ํด๋ž˜์Šค, ์ฝ˜ํ…ํŠธํ”„๋กœ๋ฐ”์ด๋”๋ฅผ ์ƒ์†๋ฐ›์•„์„œ ๋งŒ๋“œ๋Š” ํด๋ž˜์Šค, ๋ธŒ๋กœ๋“œ์บ์ŠคํŠธ๋ฆฌ์‹œ๋ฒ„๋ฅผ ์ƒ์†๋ฐ›์•„์„œ ๋งŒ๋“œ๋Š” ํด๋ž˜์Šค)

 

• ํ™”๋ฉด ๊ตฌ์„ฑ์€ View ํด๋ž˜์Šค๋ฅผ ์ด์šฉํ•œ๋‹ค. (Activity ์ž์ฒด๋Š” ๋ฐฑ์ƒ‰ ๋„ํ™”์ง€)
• TextView, ImageView, Button, EditText ๋“ฑ ๋‹ค์–‘ํ•œ View ํด๋ž˜์Šค๋“ค์ด ์ œ๊ณต๋œ๋‹ค. 
• Activity ์—์„œ setContentView( ) ํ•จ์ˆ˜๋ฅผ ์ด์šฉํ•ด View ๊ฐ์ฒด๋ฅผ Activity ํ™”๋ฉด์— ์ถœ๋ ฅ

 

 

View ํด๋ž˜์Šค

• TextView : ๋ฌธ์ž์—ด ์ถœ๋ ฅ View ํด๋ž˜์Šค
• ImageView : ์ด๋ฏธ์ง€ ์ถœ๋ ฅ View ํด๋ž˜์Šค
• EditText : ์œ ์ € ๊ธ€ ์ž…๋ ฅ View ํด๋ž˜์Šค
• Button : ๋ฒ„ํŠผ View ํด๋ž˜์Šค

์ด์™ธ์—๋„ ์ƒ๋‹นํžˆ ๋งŽ๊ณ , ์•ˆ๋“œ๋กœ์ด๋“œ์ŠคํŠœ๋””์˜ค ๋ฒ„์ „ ์—…๊ทธ๋ ˆ์ด๋“œ ๋˜๋ฉด์„œ๋„ ๊ณ„์† ์ถ”๊ฐ€๋จ

 

 

• View : ๋ชจ๋“  View ํด๋ž˜์Šค๋“ค์˜ ์ตœ์ƒ์œ„ ํด๋ž˜์Šค.
• ViewGroup : ๋‹ค๋ฅธ View ๊ฐ์ฒด๋ฅผ ํ•œ๊บผ๋ฒˆ์— ์ œ์–ดํ•˜๊ธฐ ์œ„ํ•œ Container ๊ธฐ๋Šฅ. (๋ทฐ์˜ ์„œ๋ธŒ๋‹ˆ๊นŒ ๋‹น์—ฐํ•˜๊ฒ ์ง€๋งŒ, ์•กํ‹ฐ๋น„ํ‹ฐ ํ™”๋ฉด์— ์ถœ๋ ฅ ๊ฐ€๋Šฅ. ์ด ๋ทฐ๊ทธ๋ฃน์ด ์ถœ๋ ฅ๋˜๋ฉด ์ž์ฒด UI๋Š” ๊ฐ€์ง€์ง€ ์•Š์Œ -> ํ™”๋ฉด์— ์•„๋ฌด๊ฒƒ๋„ ์•ˆ ๋‚˜์˜ด / ์“ฐ๋Š” ์ด์œ : ๋‹ค๋ฅธ ๋ทฐ ๊ฐ์ฒด ์—ฌ๋Ÿฌ ๊ฐœ๋ฅผ ์ด ๋ทฐ๊ทธ๋ฃน์— Add ์‹œ์ผœ์„œ ํ•œ๊บผ๋ฒˆ์— ์ œ์–ดํ•˜๊ธฐ ์œ„ํ•จ)
• TextView, ImageView, EditText, Button ๋“ฑ…

 

 


 

11๊ฐ• Layout XML ์„ ์ด์šฉํ•œ ํ™”๋ฉด ๊ตฌ์„ฑ

 


 

(1) Activity ์ฝ”๋“œ์—์„œ ์ง์ ‘ ํ™”๋ฉด ๊ตฌ์„ฑ

• View ํด๋ž˜์Šค๋ฅผ Activity ์—์„œ ์ง์ ‘ ์ƒ์„ฑํ•ด ํ™”๋ฉด ๊ตฌ์„ฑ.

class MainActivity : AppCompatActivity() {

 override fun onCreate(savedInstanceState: Bundle?) {
  //...............................
  val image = ImageView(this).also {
    it.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.logo_1))
  }
  val layout = LinearLayout(this).apply {
    //.................
 }
 setContentView(layout)
 }
}

Activity๋ฅผ ๋งŒ๋“ค์–ด์•ผ ํ™”๋ฉด์ด ์‹คํ–‰๋˜๊ณ , ์ด Activityํ™”๋ฉด์„ View ํด๋ž˜์Šค๋กœ ๊ตฌํ˜„ํ•ด ์ฃผ์–ด์•ผ ํ•จ

AppCompatActivity()๋ฅผ ์ƒ์†๋ฐ›์€ MainActivity๋ผ๋Š” Activity๊ฐ€ ๋งŒ๋“ค์–ด์ ธ ์žˆ์Œ
์ด AppCompatActivity๊ฐ€ MainActivity์˜ ์„œ๋ธŒ ํด๋ž˜์Šค์ด์ž ์•กํ‹ฐ๋น„ํ‹ฐ ํด๋ž˜์Šค๊ฐ€ ๋จ
๋Ÿฐํƒ€์ž„ ์‹œ์— ์ด ์•กํ‹ฐ๋น„ํ‹ฐ ํด๋ž˜์Šค๊ฐ€ ์‹คํ–‰์ด ๋˜๋ฉด, ์ด ์œ„์—์„œ ํ™”๋ฉด์ด ๋‚˜์˜ค๋Š”๋ฐ,
ํ™”๋ฉด์„ ์–ด๋–ป๊ฒŒ ๊ตฌ์„ฑํ•  ๊ฒƒ์ด๋ƒ ๋ช…๋ น์„ ๋‚ด๋ฆฌ๊ธฐ ์œ„ํ•ด์„œ
SetContentView()๋ฅผ ์•„๋ž˜์— ์‚ฌ์šฉํ–ˆ๊ณ ,
์ด SetContentView ํ•จ์ˆ˜์˜ ๋งค๊ฐœ๋ณ€์ˆ˜์— ๋˜์ง„ ๋ถ€๋ถ„์ด ๊ฒฐ๊ตญ ์•กํ‹ฐ๋น„ํ‹ฐ ํ™”๋ฉด์— ๋‚˜์˜ค๊ฒŒ ๋จ(layout)

(1) Code - ์•กํ‹ฐ๋น„ํ‹ฐ ์ฝ”๋“œ๋‚ด์—์„œ ๋ทฐ๊ฐ์ฒด๋ฅผ ์ง์ ‘ ์ƒ์„ฑํ•ด์„œ ์ค€๋น„ํ•˜๋Š” ๋ฐฉ๋ฒ• ์ด ์žˆ๊ณ 
(2) Layoutxml - Layout Xml ํŒŒ์ผ์„ ์ด์šฉํ•ด์„œ ํ™”๋ฉด์„ ์ค€๋น„ํ•˜๋Š” ๋ฐฉ๋ฒ•์ด ์žˆ์Œ

์ฝ”๋“œ์—์„œ ์ง์ ‘ ์ค€๋น„ํ•˜๋Š” ๋ฐฉ๋ฒ•์ด๋ผ๋Š” ๊ฒƒ์€ ์šฐ๋ฆฌ๊ฐ€ ์ž‘์„ฑํ•˜๋Š” ์•กํ‹ฐ๋น„ํ‹ฐ ์ฝ”๋“œ๋‚ด์—์„œ
ํ™”๋ฉด ์ถœ๋ ฅํ•˜๊ธฐ ํ•œ ๋ทฐ๋“ค์„ ์ง์ ‘ ์ƒ์„ฑํ•ด์„œ (ImageView, LinearLayout) ์ด๊ฑธ layout์œผ๋กœ ๋ณด๋‚ธ ๊ฒƒ

 

 

MainActivity ๋‚ด์— ํ…์ŠคํŠธ๋ทฐ/์ด๋ฏธ์ง€๋ทฐ/ํ…์ŠคํŠธ๋ทฐ ๊ฐ์ฒด ์ƒ์„ฑ ๋ฐ ๊ตฌ์„ฑ

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)


        val name = TextView (this).apply {
            typeface = Typeface.DEFAULT_BOLD
            text = "Save the Earth"
        }

        val image = ImageView(this).also {
            it.setImageDrawable(ContextCompat.getDrawable(
                this, R.drawable.logo_1
            ))
        }

        val title = TextView (this).apply {
            typeface = Typeface.DEFAULT_BOLD
            text = "์ง€๊ตฌ๋ฅผ ์ง€์ผœ์ฃผ์„ธ์š”!"
        }


        val layout = LinearLayout(this).apply {
          orientation = LinearLayout.VERTICAL
          gravity = Gravity.CENTER
            // LinearLayout์€ ๊ฐ€๋กœ๋ฐฉํ–ฅ ์„ธ๋กœ๋ฐฉํ–ฅ ๋‚˜์—ดํ•ด์ฃผ๋Š” ๋ ˆ์ด์•„์›ƒ
            addView(name, WRAP_CONTENT, WRAP_CONTENT)
            addView(image, WRAP_CONTENT, WRAP_CONTENT)
            addView(title, WRAP_CONTENT, WRAP_CONTENT)
            // name, image, title ๋ทฐ๋ฅผ ์• ๋“œ๋ทฐ
        }

        //์ตœ์ข…์ ์œผ๋กœ activity๋ฅผ ์ถœ๋ ฅํ•˜๊ธฐ ์œ„ํ•ด setContentView๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•˜๊ณ ,
        // ํ•จ์ˆ˜์˜ ๋งค๊ฐœ๋ณ€์ˆ˜์— layout์„ ๋˜์ง€๋ฉด ๊ฒฐ๊ตญ ์ด๊ฑธ ์ถœ๋ ฅํ•˜๊ฒŒ ๋จ.

        setContentView(layout)
    }
}

 

 

 

(2) Layout XML ์—์„œ ํ™”๋ฉด ๊ตฌ์„ฑ

• Layout XML ์ฝ”๋“œ์— ํ™”๋ฉด ๊ตฌ์„ฑ์„ ์œ„ํ•œ View ๋ฅผ ํƒœ๊ทธ๋กœ ๋“ฑ๋ก

์ถœ๋ ฅํ•˜๊ณ ์ž ํ•˜๋Š” ๋ทฐ ํด๋ž˜์Šค๋ช…๊ณผ ๋Œ€์†Œ๋ฌธ์ž๊นŒ์ง€ ๋™์ผํ•œ ํƒœ๊ทธ๋ช…์„ ์“ฐ๋ฉด ๋จ
ํ™”๋ฉด์— ๋ฌธ์ž์—ด์„ ์ถœ๋ ฅํ•˜๊ฒ ๋‹ค๋ฉด ํƒœ๊ทธ๋ช…์ด TextView์ธ xmlํŒŒ์ผ์„ ์ •์˜ํ•ด์„œ,
์ด xmlํŒŒ์ผ์„ ์•กํ‹ฐ๋น„ํ‹ฐ ์ฝ”๋“œ์—๋‹ค๊ฐ€ ํ™”๋ฉด์— ๋‚˜์™€๋ผ ๋ช…๋ น์„ ๋‚ด๋ ค์„œ ์ถœ๋ ฅ ์‹œํ‚ฌ ์ˆ˜๋„ ์žˆ์Œ

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=http://schemas.android.com/apk/res/android ……………………… >
<TextView ……………………….. />
</LinearLayout>

 

res - layout - activty_main.xml์— ์ž‘์„ฑ

์•„๊นŒ MainActivity ์ฝ”๋“œ์—์„œ ์ž‘์„ฑํ–ˆ๋˜ ๊ฒƒ์„ ๊ทธ๋Œ€๋กœ xmlํŒŒ์ผ๋กœ ๋Œ๋ ค์ฃผ๋ฉด ๋จ
์ƒ์œ„๋ฅผ LinearLayout์œผ๋กœ ์ˆ˜์ •, ์†์„ฑ ์ง€์ • android: 


 

12๊ฐ• ๊ธฐ์ดˆ ์†์„ฑ

 


 

id ์†์„ฑ

•Layout XML ์— ๋“ฑ๋ก๋˜๋Š” View ๊ฐ์ฒด ์‹๋ณ„์ž

<TextView
android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hello"/>

 

•findViewById( ) ํ•จ์ˆ˜๋กœ View ๊ฐ์ฒด ํš๋“

val textView1: TextView = findViewById(R.id.text1)

 

layout_width, layout_height ์†์„ฑ

•๋ทฐ์˜ ์‚ฌ์ด์ฆˆ๋ฅผ ์ง€์ •, ํ•„์ˆ˜ ์†์„ฑ
•match_parent, wrap_content, 100dp 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button1"
android:backgroundTint="#ff0000"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button2"
android:backgroundTint="#00ff00"/>
<Button
android:layout_width="150dp"
android:layout_height="150dp"
android:text="Button3"
android:backgroundTint="#0000ff"/>
</LinearLayout>

 

 

 

margin, padding ์†์„ฑ

•margin ์€ ๋ทฐ์™€ ๋ทฐ ์‚ฌ์ด์˜ ๊ฐ„๊ฒฉ, padding์€ ๋ทฐ์˜ ์ปจํ…์ธ ์™€ ๋ทฐ ํ…Œ๋‘๋ฆฌ ์‚ฌ์ด์˜ ๊ฐ„๊ฒฉ
•padding, margin ์†์„ฑ์„ ์ด์šฉํ•˜๋ฉด 4๋ฐฉํ–ฅ ๋ชจ๋‘ ๋™์ผํ•œ ์‚ฌ์ด์ฆˆ๋กœ ๊ฐ„๊ฒฉ์ด ์„ค์ •
•ํ•œ ๋ฐฉํ–ฅ์˜ ๊ฐ„๊ฒฉ๋งŒ ์„ค์ •ํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด paddingLeft, paddingRight, paddingTop, paddingBottom์™€ layout_marginLeft, layout_marginRight, layout_marginTop, layout_marginBottom ์†์„ฑ์„ ์ด์šฉ

 

visibility ์†์„ฑ

•visibility ์†์„ฑ์€ ๋ทฐ๊ฐ€ ํ™”๋ฉด์— ์ถœ๋ ฅ๋˜์–ด์•ผ ํ•˜๋Š”์ง€์— ๋Œ€ํ•œ ์„ค์ •
•visible(default), invisible, gone ๊ฐ’์œผ๋กœ ์„ค์ •
•invisible ๊ณผ gone ์€ ๋ชจ๋‘ ํ™”๋ฉด์— ๋ทฐ๊ฐ€ ๋ณด์ด์ง€ ์•Š๊ฒŒ ํ•˜์ง€๋งŒ ์‚ฌ์ด์ฆˆ๋ฅผ ํ™•๋ณดํ•˜๋Š”์ง€์— ๋Œ€ํ•œ ์ฐจ์ด๊ฐ€ ์žˆ๋‹ค.

 

 

 


 

13๊ฐ• TextView

 


 

TextView ์†์„ฑ

•android:text – TextView ์— ์ถœ๋ ฅ๋˜๋Š” ๋ฌธ์ž์—ด ์ง€์ •
•android:textColor – ๋ฌธ์ž์—ด ์ปฌ๋Ÿฌ
•android:textSize – ๋ฌธ์ž์—ด ์‚ฌ์ด์ฆˆ
•android:textStyle – ๋ฌธ์ž์—ด ์Šคํƒ€์ผ

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="helloworld"
android:textColor="#FF0000"
android:textSize="20sp"
android:textStyle="bold"/>

 

•android:autoLink
•TextView ์— ์ถœ๋ ฅ๋˜๋Š” ๋ฌธ์ž์—ด์„ ๋ถ„์„ํ•ด ์ž๋™ ๋งํฌ ์ถ”๊ฐ€
•web, email, phone ๋“ฑ์„ ๊ฐ’์œผ๋กœ ์ง€์ •

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="SeSAC - ์›นํŽ˜์ด์ง€ : https://ssac.seoul.kr/, ์ „ํ™”๋ฒˆํ˜ธ : 02-3667-7304, ์ด๋ฉ”์ผ: ssac@sba.seoul.kr"
android:autoLink="web|email|phone"/>

 

 

• android:maxLines - ๋ฌธ์ž์—ด์ด ํŠน์ • ๋ผ์ธ ๊นŒ์ง€๋งŒ ์ถœ๋ ฅ๋˜๊ฒŒ ์„ค์ •
• ellipsize - ์ค„์ž„ํ‘œ์‹œ, end, start, middle

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/long_text"
android:maxLines="3"
android:ellipsize="end"/>

 

 


 

14๊ฐ• ImageView

 


 

ImageView ์†์„ฑ

•android:src - ์ถœ๋ ฅ๋  ์ด๋ฏธ์ง€ ์ง€์ •
•maxWidth, maxHeight - ํ™”๋ฉด์— ์ถœ๋ ฅ๋  ๋ทฐ์˜ ์ตœ๋Œ€ ์‚ฌ์ด์ฆˆ ์ง€์ •
•adjustViewBounds - ์ข…ํšก๋น„ ์œ ์ง€

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/lake"
android:maxWidth="100dp"
android:maxHeight="100dp"
android:adjustViewBounds="true"/>

 

scaleType

•ImageView ์— ์ถœ๋ ฅ๋˜๋Š” ์ด๋ฏธ์ง€ ๋น„์œจ, ํฌ๊ธฐ ์„ค์ •

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/lake"
android:scaleType="center"/>

 

•center : ์ด๋ฏธ์ง€ ์›๋ณธ ์‚ฌ์ด์ฆˆ ์œ ์ง€, ์ด๋ฏธ์ง€ ์ค‘์•™์„ ImageView ์— ์ถœ๋ ฅ

•centerCrop : ์ด๋ฏธ์ง€์˜ ๊ฐ€๋กœ/์„ธ๋กœ ์ค‘ ์งง์€ ์ชฝ์„ ImageView ์— ๊ฝ‰ ์ฐจ๊ฒŒ ์ถœ๋ ฅ

•centerInside : ์ด๋ฏธ์ง€์˜ ๊ฐ€๋กœ/์„ธ๋กœ ์ค‘ ๊ธด ์ชฝ์„ ImageView ์— ๊ฝ‰ ์ฐจ๊ฒŒ ์ถœ๋ ฅ

 

•fitStart : ๊ฐ€๋กœ/์„ธ๋กœ ๋น„์œจ์„ ์œ ์ง€ํ•˜์—ฌ ImageView ์•ˆ์— ์ถœ๋ ฅ. ImageView ์˜ ์ขŒ์ธก์ƒ๋‹จ์„ ๊ธฐ์ค€์œผ๋กœ ์ •๋ ฌ
•fitEnd : ๊ฐ€๋กœ/์„ธ๋กœ ๋น„์œจ์„ ์œ ์ง€ํ•˜์—ฌ ImageView ์•ˆ์— ์ถœ๋ ฅ. ImageView ์˜ ์šฐ์ธกํ•˜๋‹จ์„ ๊ธฐ์ค€์œผ๋กœ ์ •๋ ฌ
•fitCenter : ๊ฐ€๋กœ/์„ธ๋กœ ๋น„์œจ์„ ์œ ์ง€ํ•˜์—ฌ ImageView ์•ˆ์— ์ถœ๋ ฅ. ImageView ์˜ ์ค‘์•™์„ ๊ธฐ์ค€์œผ๋กœ์ •๋ ฌ
•fitXY : ๊ฐ€๋กœ/์„ธ๋กœ ๋น„์œจ์— ์ƒ๊ด€์—†์ด ImageView ์— ๊ฝ‰ ์ฐจ๊ฒŒ ์ถœ๋ ฅ. ์ข…ํšก๋น„ ๋ฌด์‹œ

 

Lab - ImageView ์†์„ฑ

 

 


 

15๊ฐ• Button, EditText

 


 

Button

•Button : ์œ ์ € ์ด๋ฒคํŠธ ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•œ View
•CheckBox : ๋‹ค์ค‘ ์„ ํƒ
•RadioButton : ๋‹จ์ผ ์„ ํƒ, ๋™์ผ RadioGroup ๋‚ด์—์„œ ํ•˜๋‚˜๋งŒ ์„ ํƒ์ด ๊ฐ€๋Šฅ

<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="radio1"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="radio2"/>
</RadioGroup>

 

 

EditText

•android:lines – EditText ๊ฐ€ ํ™”๋ฉด์— ์ถœ๋ ฅ๋  ๋ผ์ธ์ˆ˜
•android:maxLines – ์—ฌ๋Ÿฌ์ค„ ์ž…๋ ฅ์„ ์œ„ํ•ด ๋Š˜์–ด๋‚˜๋Š” ์ตœ๋Œ€ ๋ผ์ธ์ˆ˜
•android:inputType – ํ‚ค๋ณด๋“œ ์ œ์–ด, ํ‚ค๋ณด๋“œ ๋ชจ๋“œ, ํ•œ์ค„ ์ž…๋ ฅ ์ œ์–ด

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="phone number"
android:inputType="phone"/>

 

 

๋ฐ˜์‘ํ˜•
 ๐Ÿ’ฌ C O M M E N T