대학교
Unit2. 03-1 SampleWidget 본문
1. 텍스트뷰
* 텍스트뷰의 text 속성
* 텍스트뷰의 textColor 속성
- 일반적으로 #AARRGGBB (Alpha/Red/Green/Blue)
- 투명도를 나타내는 Alpha값 : 투명하지않음(FF), 투명함(00), 반투명(88)
* 텍스트뷰의 TextSize 속성
- dp/sp.
- sp 권장. > 단말의 해상도에 따라 글자의 크기를 일정한 크기로 보일 수 있게 하며, 폰트 변경 시 반영됨.
* textStyle
- "normal", "bold", "italic" 설정 가능. 중복으로 설정 원할 시 '|' 기호 사용하여 설정 가능.
* typeFace
- 일반적으로 "normal", "sans", "serif", "monospace" 제공
*maxLines
2. 버튼
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="선택"
android:textSize="24sp"
android:textStyle="bold"
android:gravity="center"
/>
<RadioGroup
android:id="@+id/radioGroup01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="20dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
>
<RadioButton
android:id="@+id/radio01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="남성"
android:textColor="#ff55aaff"
android:textStyle="bold"
android:textSize="24sp"
/>
<RadioButton
android:id="@+id/radio02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="여성"
android:textColor="#ff55aaff"
android:textStyle="bold"
android:textSize="24sp"
/>
</RadioGroup>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal"
android:orientation="horizontal"
android:padding="20dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="하루종일"
android:textSize="24sp"
android:paddingRight="10dp"
android:textColor="#ff55aaff"
/>
<CheckBox
android:id="@+id/allDay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
</LinearLayout>
3. 에디트텍스트
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:id="@+id/usernameInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="24sp"
android:inputType="text"
android:hint="이름을 입력하세요" />
</LinearLayout>
4. 이미지뷰, 이미지 버튼
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageButton
android:id="@+id/imageButton"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginLeft="40dp"
android:layout_marginTop="40dp"
android:background="@drawable/ic_launcher_foreground"
android:contentDescription="ok button"></ImageButton>
<ImageView
android:id="@+id/imageView"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginLeft="160dp"
android:layout_marginTop="160dp"
android:background="@drawable/ic_launcher_background"
android:contentDescription="person button"></ImageView>
</LinearLayout>
※ 이미지 파일이 없어 launcher 파일 이용. 이미지 파일 drawable에 넣는 방법 다시 익히기
'공대 > 안드로이드 스튜디오' 카테고리의 다른 글
안드로이드 스튜디오: 버튼 size 조정 (0) | 2022.04.12 |
---|---|
4/4 Java Class (0) | 2022.04.10 |
클래스 설명 관련 소스 파일 (0) | 2022.03.23 |
안드로이드 스튜디오 HAXM 오류 (0) | 2022.03.17 |
안드로이드 스튜디오: 뷰(view) (0) | 2022.03.17 |