1. TextView 기초
2. 상용 속성
NO
속성
역할.
1
android:text
텍스트 정보 보이 기
2
android:textColor
텍스트 색상 설정
3
android:textSize
텍스트 크기 설정
4
android:textStyle
텍스트 글꼴 설정
5
android:typeface
텍스트 글꼴 설정
6
android:singleLine
텍스트 단일 줄 표시 여부
7
android:lines
텍스트 줄 수 설정
8
android:maxLines
텍스트 표시 최대 줄 수
9
android:minLines
텍스트 표시 최소 줄 수 설정
10
android:ellipsize
생략 번호 보일 지 여부 (NO. 5 필요)
11
android:drawableStart
텍스트 시작 에 그림 추가 (RTL 에 적합)
12
android:drawableEnd
텍스트 끝 에 그림 추가 (RTL 에 적합)
13
android:drawableTop
텍스트 상단 에 그림 추가
14
android:drawableBottom
텍스트 밑 에 그림 추가
15
android:drawableLeft
텍스트 왼쪽 에 그림 추가
16
android:drawableRight
텍스트 오른쪽 에 그림 추가
17
android:drawableTint
추 가 된 그림 에 착색 (API level 23)
18
android:drawablePadding
그림 의 안쪽 여백 (그림 텍스트 거리)
19
android:gravity
컨트롤 에 텍스트 내용 표시 위치
20
android:shadowColor
텍스트 그림자 색상
21
android:shadowDx
텍스트 그림자 x 축 거리
22
android:shadowDy
텍스트 그림자 y 축 거리
23
android:shadowRadius
텍스트 그림자 의 반지름
24
android:lineSpacingExtra
줄 간격 설정
25
android:lineSpacingMultiplier
줄 간격 배수 설정
26
android:maxLength
표시 할 텍스트 길이 제한
27
android:ems
TextView 폭 을 N 자로 제한 합 니 다.
28
android:minEms
TextView 너비 최대 N 글자 길이 제한
29
android:maxEms
TextView 너비 최대 N 글자 길이 제한
30
android:textScaleX
글자 간격 설정
31
android:height
텍스트 영역 높이 설정
32
android:maxHeight
텍스트 영역의 최대 높이 설정
33
android:minHeight
텍스트 영역의 최소 높이 설정
34
android:width
텍스트 영역의 너비 설정
35
android:maxWidth
텍스트 영역의 최대 너비 설정
36
android:minWidth
텍스트 영역의 최소 너비 설정
2.1 android:text
2.2 android:textColor
#3F51B5
2.3 android:textSize
- dimen.xml
16dp
16dp
16sp
- sp dp :[ Android SP DP - ](http://droidyue.com/blog/2016/09/05/dp-vs-sp-in-android/)
---
##### 2.4 android:textStyle
- (** :bold|italic**)
- normal( )

- italic( )

- bold( )

---
##### 2.5 android:typeface
-
- normal
- sans
- serif
- monospace
---
##### 2.6 ~~android:singleLine~~
- ,
android:singleLine="false"

-
android:singleLine="true"

- , **android:maxLines="1"**
---
##### 2.7 android:lines
-
- 2
android:lines="2"
2, 2 ,
2, 2 ,
---
##### 2.8 android:maxLines
- 0
- 0,
- 1, **android:singleLine="true"**,
android:maxLines="1"

---
##### 2.9 android:minLines
-
-
-
---
##### 2.10 android:ellipsize
-
- end
- start
- middle
- marquee ( ,cpu )
- none ( )
---
##### 2.11~2.18
- ,
android:drawableTop="@mipmap/ic_launcher"
android:drawableBottom="@mipmap/ic_launcher"
android:drawableLeft="@mipmap/ic_launcher"
android:drawableRight="@mipmap/ic_launcher"
android:drawablePadding="@dimen/activity_horizontal_margin"
-

-
---
##### 2.19 android:gravity
-
| | |
|:---:|:---:|
|center| |
|center_vertical| |
|center_horizontal| |
|left| |
|right| |
|top| |
|bottom| |
|start| ( RLT)|
|end| ( RLT)|
|clip_vertical| |
|clip_horizontal| |
|fill|fill_vertical fill_horizontal, |
|fill_horizontal|left right, |
|fill_vertical|top bottom, |
---
##### 2.20~2.23
-
android:shadowColor="@color/colorAccent"
android:shadowDx="100"
android:shadowDy="-10"
android:shadowRadius="2"/>
-

- android:shadowColor
- android:shadowDx x , px,
- android:shadowDy y , px,
- android:shadowRadius , px,
---
#### 3.
|NO| |
|:---:|:---:|
|1|TextView |
|2|TextView XML |
|3|TextView |
|4|TextView |
|5|TextView |
---
##### 3.1 TextView
- drawable
- drawable textColor
---
##### 3.2 TextView XML
- TextView , “1 ”

-
int robotNum=3;
tvDemo.setText(robotNum+" ");
- , **Android Studio**
-
int robotNum=3;
tvDemo.setText(getString(R.string.robot_num,robotNum));
%d
-
- [《Android String (String.format() )》lance_ ](http://www.jianshu.com/p/9855d6a7596d)
---
##### 3.3 TextView
- , , , , , .
-
- [《【Android】 SpannableStringBuilder》 ](http://www.jianshu.com/p/f004300c6920)
- [《 SpannableString 》 ](http://www.jianshu.com/p/84067ad289d2)
---
##### 3.4 TextView
-

- [《TextView- 》](http://www.jianshu.com/p/d8f50509b1e9)
---
##### 3.5 TextView
- string **
**
---
#### 4.
|NO| |
|:---:|:---:|
|1|java drawable |
---
##### 4.1 java drawable
- XML **android:drawableLeft** , java ,
setCompoundDrawables(@Nullable Drawable left, @Nullable Drawable top,
@Nullable Drawable right, @Nullable Drawable bottom)
- ,
tv.setCompoundDrawables(getResources().getDrawable(R.mipmap.ic_launcher),null,null,null);
- ,
-
Drawable drawable = getResources().getDrawable(R.mipmap.ic_launcher);
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
tv.setCompoundDrawables(drawable,null,null,null);
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.