티스토리 뷰

  • 텍스트 뷰
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
1. text : 텍스트 뷰에 보이는 문자열을 설정할 수 있음
2. textColor : 텍스트 뷰에서 표시하는 문자열의 색상을 변경함
:색상 설정은 "#AARRGGBB" 포맷을 일반적으로 사용한다(Alpha,Red,Green,Blue)
:투명도를 나타내는 Alpha(색상만 사용할때 "FF",투명,"00",반투명,"88")
 
3. textSize : 텍스트 뷰에서 표시하는 문자열의 크기를 설정함
("dp"나 "sp" 또는 "px" 등의 단위 값을 사용한다.
 
4. textStyle : 텍스트 뷰에서 표시하는 문자열의 스타일 속성을 설정함
("normal","bold","italic"등의 값을 지정할 수 있음)
 
5. typeFace: 텍스트 뷰에서 표시하는 문자열의 폰트를 설정함
("normal","sans","serif","monospace")
 
6.maxLines="1" : 텍스트 뷰에서 표시하는 문자열이 한줄로만 표시되도록 설정함.
cs
  • 기본 위젯 - 텍스트뷰의 속성 사용
1
2
3
4
5
6
7
8
9
10
새로운 프로젝트 파일 : example_BasicWidget
 
XML 파일에서 view Fewer Properties에서 여러가지 속성들을 건드려보기!
 
1. lineSpacingMultiPller 스페이스 간격 조정 (단위 dp)
2. MaxLine 하나의 줄로 만든다 , 여러가지줄을
3. TextSize
4. TextColor
5. Background
 
cs








  • ToggleButton 사용해보기
1
2
3
4
5
6
7
8
9
ON/OFF
 
1. ConstraintLayout 에서 ToggleButton 추가 시킨다.
 
2. 이후에 체크 박스 추가 시킨다.
 
3. 그이후 가운데 TextView 밑으로 라디오 버튼 (남자,여자) 을 만들어 준다.
 
4. 다시 MainActivity.java 로 와서
cs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package com.example.example_basicwidget;
 
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.RadioButton;
 
public class MainActivity extends AppCompatActivity {
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
 
        RadioButton radioButton = (RadioButton)findViewById(R.id.radioButton);
        boolean checked = radioButton.isChecked();          // 라디오 버튼 체크하는부분
   
 
 
 
    }
}
cs
1
2
3
4
5
6
7
8
9
10
11
12
입력을 해준다
 
 
5. 이제 또다시 입력상자중에서 -> plain Text 일반적인 입력 상자 선택
 
6. 입력 상자를 위아래를 연결선으로 연결 시키도록 할것
 
7. plain Text의 글자를 없애고 -> Hint 에 " 아이디를 입력하시오 "를 입력한다.(밑에 희미하게 보이는것)
 
8. plain Text에서 input Type이 있는데, (숫자. 문자 )에 따른 키패드가 띄워지는것이 달라진다.
 
9. 또 + ImageView 추가 한뒤 -> 안드로이드 기본화면을 넣어 준다. (안드로이드 아이콘)
cs

ImageView
1
app:srcCompat="@mipmap/ic_launcher"
cs
안드로이드 기본 API에 제공 

10. 소스코드

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.example_basicwidget.MainActivity">
 
    <ToggleButton
        android:text="ToggleButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/toggleButton"
        android:layout_above="@+id/textView"
        android:layout_centerHorizontal="true"
        tools:layout_editor_absoluteX="132dp"
        android:layout_marginTop="16dp"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toTopOf="@+id/textView"
        android:layout_marginBottom="8dp" />
 
    <TextView
        android:text="Hello World Computer engine"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/textView"
        android:textColorLink="@android:color/holo_purple"
        android:textStyle="normal|bold"
        android:textColor="@color/colorAccent"
        android:typeface="serif"
        android:background="@color/colorPrimaryDark"
        android:textSize="24sp"
        android:maxLines="1"
        android:layout_centerVertical="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        tools:layout_editor_absoluteY="235dp"
        tools:layout_editor_absoluteX="0dp" />
 
    <CheckBox
        android:text="CheckBox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/toggleButton"
        android:layout_alignParentRight="true"
        android:id="@+id/checkBox"
        android:layout_marginStart="8dp"
        app:layout_constraintLeft_toRightOf="@+id/toggleButton"
        android:layout_marginLeft="8dp"
        android:layout_marginEnd="16dp"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_marginRight="16dp"
        android:layout_marginTop="16dp"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toTopOf="@+id/textView"
        android:layout_marginBottom="8dp" />
 
    <RadioButton
        android:text="여자"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/radioButton"
        android:layout_weight="1"
        tools:layout_editor_absoluteY="331dp"
        tools:layout_editor_absoluteX="103dp" />
 
    <RadioButton
        android:text="남자"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/radioButton2"
        android:layout_weight="1"
        tools:layout_editor_absoluteX="99dp"
        android:layout_marginTop="8dp"
        app:layout_constraintTop_toBottomOf="@+id/radioButton" />
 
    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="textPersonName"
        android:ems="10"
        tools:layout_editor_absoluteY="5dp"
        tools:layout_editor_absoluteX="0dp"
        android:id="@+id/editText"
        android:hint="아이디 입력하세요" />
 
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:srcCompat="@mipmap/ic_launcher"
        android:id="@+id/imageView"
        app:layout_constraintRight_toLeftOf="@+id/radioButton2"
        android:layout_marginEnd="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginStart="16dp"
        app:layout_constraintLeft_toLeftOf="parent"
        android:layout_marginLeft="16dp"
        android:layout_marginTop="8dp"
        app:layout_constraintTop_toBottomOf="@+id/textView"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="16dp" />
 
    <RadioGroup
        android:layout_width="86dp"
        android:layout_height="89dp"
        tools:layout_editor_absoluteY="323dp"
        tools:layout_editor_absoluteX="84dp" >
 
    </RadioGroup>
</android.support.constraint.ConstraintLayout>
cs
 






공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
글 보관함