EditText

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:lines="1" />//singleline 대신 사용



CheckBox

res/layout/activity.xml

<CheckBox
android:id="@+id/main_checkbox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:button="@drawable/checkbox" //커스텀 원하면 사용
android:checked="false"
android:text="알림설정" />


res/drawable/checkbox

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:drawable="@drawable/r1"/>
<item android:drawable="@drawable/r2"/>
</selector>


java/MainActivity

@BindView(R.id.main_checkbox) CheckBox mainCheckbox;
//변경감지할떄
mainCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
Toast.makeText(MainActivity.this, "체크됐당", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(MainActivity.this, "아니당", Toast.LENGTH_SHORT).show();
}
}
});
//체크상태 가져와서 설정
if (mainCheckbox.isChecked()) {
//mainCheckbox.setChecked(true);
}




RadioButton

res/layout/maina_main.xml

<RadioGroup
android:id="@+id/main_radio_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">

<RadioButton
android:id="@+id/main_radio_man_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="남자" />

<RadioButton
android:id="@+id/main_radio_girl_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="여자" />
</RadioGroup>

res/java/MainActivity.java

@BindView(R.id.main_radio_group) RadioGroup mainRadioGroup;
@BindView(R.id.main_toggle_btn) ToggleButton mainToggleBtn;

//변경감지
mainRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
if (checkedId == R.id.main_radio_man_btn) {
Toast.makeText(MainActivity.this, "남자선택", Toast.LENGTH_SHORT).show();
} else if (checkedId == R.id.main_radio_girl_btn) {
Toast.makeText(MainActivity.this, "여자선택", Toast.LENGTH_SHORT).show();
}
}
});

int id = mainRadioGroup.getCheckedRadioButtonId();
if (id == R.id.main_radio_girl_btn) {
//mainRadioGroup.check(R.id.main_radio_girl_btn);
}




ToggleButton


res/layout/activity_main.xml

<ToggleButton
android:id="@+id/main_toggle_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:background="@drawable/togglebtn"//이미지설정
android:textOff="No"
android:textOn="yes" />


res/drawable/togglebtn

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:drawable="@drawable/r1"/>
<item android:drawable="@drawable/r2"/>
</selector>


res/java/MainActivity.java

@BindView(R.id.main_toggle_btn) ToggleButton mainToggleBtn;
mainToggleBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mainToggleBtn.isChecked()) {
Toast.makeText(MainActivity.this, "체크됐넴", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(MainActivity.this, "체크됐넴", Toast.LENGTH_SHORT).show();
}
}
});
boolean check = mainToggleBtn.isChecked();





Switch

res/layout/activity_main.xml

<Switch
android:id="@+id/main_switch"
android:text="swich"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textOn="Yes"
android:textOff="No"
android:thumb="@drawable/ic_launcher_foreground"
android:track="@drawable/ic_launcher_background"/>
<!--
thumb = 안에 움직이는 것 모양
track = 감싸고있는 틀
switchMinWidth = 글자와 스위치사이 간격
-->


res/java/MainActivity.java

@BindView(R.id.main_switch) Switch mainSwitch;
mainSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
Toast.makeText(MainActivity.this, "체크됐당", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(MainActivity.this, "체크 아니당", Toast.LENGTH_SHORT).show();
}
}
});
boolean check = mainSwitch.isChecked();





ProgressBar

res/layout/activity_main.xml

<ProgressBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:indeterminateOnly="true"
style="?android:attr/progressBarStyleLarge"/>

<ProgressBar
android:id="@+id/main_progress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="100"
android:progress="50"
style="?android:attr/progressBarStyleHorizontal"/>

<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminateDrawable="@drawable/animationprogress"/>

<ProgressBar
android:layout_width="match_parent"
android:layout_height="30dp"
android:progressDrawable="@drawable/horiprogress"
android:max="100"
android:progress="50"
android:secondaryProgress="70"
style="?android:attr/progressBarStyleHorizontal"/>
<!--
indeterminateOnly = true면 나타나고 false면 사라짐
indeterminate = 무한반복 여부
indeterminateDrawable = progressbar로 보여줄 이미지 설정
indeterminateDuration = 반복될때 반복시간
indeterminateBehavior = 행동방식
-->

res/drawable/animationprogress

<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false">
<item android:drawable="@drawable/a1" android:duration="200"/>
<item android:drawable="@drawable/a2" android:duration="200"/>
<item android:drawable="@drawable/a3" android:duration="200"/>
<item android:drawable="@drawable/a4" android:duration="200"/>
<item android:drawable="@drawable/a5" android:duration="200"/>
<item android:drawable="@drawable/a6" android:duration="200"/>
<item android:drawable="@drawable/a7" android:duration="200"/>
</animation-list>


res/drawable/horiprogress

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<corners android:radius="30dp" />
<gradient
android:angle="270"
android:centerColor="#c50aff70"
android:centerY="0.75"
android:endColor="#90ff99"
android:startColor="#e5fff6" />
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<corners android:radius="30dp" />
<gradient
android:angle="270"
android:centerColor="#0003ff"
android:centerY="0.75"
android:endColor="#7282ff"
android:startColor="#dce5ff" />
</shape>
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<corners android:radius="30dp" />
<gradient
android:angle="270"
android:centerColor="#ff005e"
android:centerY="0.75"
android:endColor="#ff8185"
android:startColor="#ffa4a4" />
</shape>
</clip>
</item>
</layer-list>


res/java/MainActivity.java

@BindView(R.id.main_progress) ProgressBar mainProgress;
mainProgress.setMax(10000);
mainProgress.setSecondaryProgress(5000);
mainProgress.setProgress(3000);




circle progress를 치수조절하고 싶을때 

res/layout/activity_main.xml

<ProgressBar
android:id="@+id/main_progress"
android:layout_width="200dp"
android:layout_height="200dp"
android:progressDrawable="@drawable/circular_progress_bar"
android:background="@drawable/circular_progress_bar_bg"
android:indeterminate="false"
android:max="100"
android:progress="50"
style="?android:attr/progressBarStyleHorizontal"/>


res/drawable/circular_progress_bar

<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="270"
android:toDegrees="270">//각도
<shape
android:innerRadiusRatio="3"
android:shape="ring"
android:thickness="15sp">
<solid android:color="@color/red" />
</shape>
</rotate>


res/drawable/circular_progress_bar_bg

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadiusRatio="3"
android:shape="ring"
android:thickness="15dp"
android:useLevel="false">
<solid android:color="#CCC" />
</shape>

+애니메이션

res/java/MainActivity.java

@BindView(R.id.main_progress) ProgressBar mainProgress;

ObjectAnimator animator = ObjectAnimator.ofInt(mainProgress,"progress",0,80);
animator.setDuration(2000);//milliseconds
animator.setInterpolator(new DecelerateInterpolator());
animator.start();//mainProgress.clearAnimation();


SeekBar

res/layout/activity_main.xml

<SeekBar
android:id="@+id/main_seek_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:thumb="@drawable/seekbar"/>
<SeekBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="5"
android:progress="3"
style="@style/Widget.AppCompat.SeekBar.Discrete"/>


res/drawable/seekbar

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/r2" android:state_pressed="true" android:state_window_focused="true"/>
<item android:drawable="@drawable/r2" android:state_focused="true" android:state_window_focused="true"/>
<item android:drawable="@drawable/r2" android:state_selected="true" android:state_window_focused="true"/>
<item android:drawable="@drawable/r2"/>
</selector>



res/java/MainActivity.java

@BindView(R.id.main_seek_bar) SeekBar mainSeekBar;
mainSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
//사용자가 prgress 변경을 끝냈을때 호출
}

@Override
public void onStartTrackingTouch(SeekBar seekBar) {
//사용자가 thumb를 선택하여 progress변경을 시작할 떄 호출
}

@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
//progress가 변경되면 호출.사용자가 직접 ui통해 변경하면 fromUser = true ,code로 변경되면 false
}
});





RatingBar

res/layout/activity_main.xml

<RatingBar
android:id="@+id/main_rating_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="5"
android:rating="1.5"
android:stepSize="0.1"
android:progressDrawable="@drawable/ratingbar"/>
<!--
android:layout_width="wrap_content" width는 꼭 wrap으로
isIndicator=RatingBar를 사용자가 변경할 수 없게 함
numStars = 화면에 나타나는 별의 개수
rating = 별점의 값
stepSize= 변경의 최소단위(1칸만 해당)
-->


res/drawable/ratingbar

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background" android:drawable="@drawable/ratingbar_empty" />
<item android:id="@android:id/secondaryProgress" android:drawable="@drawable/ratingbar_empty" />
<item android:id="@android:id/progress" android:drawable="@drawable/r2" />
</layer-list>


res/java/MainActivity.java

@BindView(R.id.main_rating_bar) RatingBar mainRatingBar;
mainRatingBar.setRating(1.5f);//값설정
//RatingBar의 값이 변경되면 호출
mainRatingBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
@Override
public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
//사용자 UI를 통해 변경한 경우 fromUser true
if (fromUser) {
Toast.makeText(MainActivity.this, "rating" + rating, Toast.LENGTH_SHORT).show();
}
}
});



DatePicker,TimePicker

res/layout/activity_main.xml

<DatePicker
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:calendarViewShown="false"
android:datePickerMode="calendar" />
<DatePicker
android:id="@+id/main_date_picker"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:calendarViewShown="false"
android:datePickerMode="spinner" />
<TimePicker
android:id="@+id/main_time_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:timePickerMode="spinner"/>
<!--
절대시간이용해서 시간처리 필수

timestamp = 1970.1.1을 기준으로 지금까지 얼마나 시간이 흘렀는지를 나타내는 시간(GMT,millisecond)(영국 그리니치 천문대 기준)
timeZone = 시간기준선(GMT)와 얼마나 시간이 차이나는지를 나타내는 값(대한민국 서울: +0900)
Local = 사용자의 언어와 국가로 timZone 설정에 사용 (ex:한글(ko),한국(KR))
-->


res/java/MainActivity.java

@BindView(R.id.main_date_picker) DatePicker mainDatePicker;
@BindView(R.id.main_time_picker) TimePicker mainTimePicker;
/*     Data  = java에서 날짜를 나타내는 class
Calendar = java에서 날짜를 이용한 연산을 할때 사용하는 class
SimpleDateFormat : Date String 으로 변경하거나 반대로할때 사용하는 class*/
Calendar c = Calendar.getInstance(Locale.KOREA);
c.set(Calendar.HOUR_OF_DAY,0);
c.set(Calendar.MINUTE,0);
c.set(Calendar.SECOND,0);
c.set(Calendar.MILLISECOND,0);
long lastmidnight = c.getTimeInMillis();
c.add(Calendar.DAY_OF_YEAR,1);
long nextmidnight = c.getTimeInMillis();

//String date로 변환
String ds = "2014-11-10T10:25:40.000+0900";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");//-- "timezone" 시 분 초 밀리세컨드
try {
Date d= sdf.parse(ds);
Toast.makeText(this, "시간"+d, Toast.LENGTH_SHORT).show();
} catch (ParseException e) {
e.printStackTrace();
}

//Date String으로 변환
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm",Locale.KOREA);
/*
"yyyy-MM-dd"
"yyyy-MM-dd HH:mm"
"yyyy-MM-dd'T'HH:mmZ"
"yyyy-MM-dd HH:mm:ss.SSSZ"
"yyyy-MM-dd'T'HH:mm:ss.SSSZ"
*/
String df =sdf2.format(new Date());


mainDatePicker.init(2017,10,10,new DatePicker.OnDateChangedListener(){

@Override
public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
Toast.makeText(MainActivity.this, ":"+year+":"+monthOfYear+":"+dayOfMonth, Toast.LENGTH_SHORT).show();
//,,일 가져오기
}
});

mainTimePicker.setOnTimeChangedListener(new TimePicker.OnTimeChangedListener() {
@Override
public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
//,분 가져옴
}
});
//MM dd (E) aa HH:mm   E=요일  aa =오전,오후 

val formatter = SimpleDateFormat(dateFormat, Locale.KOREA) //simpleDateFormat 쓸시 서울을 꼭명시해야 문제없다
formatter.timeZone = TimeZone.getTimeZone("Asia/Seoul")

import android.text.format.DateFormat;

String dayOfTheWeek = (String) DateFormat.format("EEEE", date); // Thursday
String day          = (String) DateFormat.format("dd",   date); // 20
String monthString  = (String) DateFormat.format("MMM",  date); // Jun
String monthNumber  = (String) DateFormat.format("MM",   date); // 06
String year         = (String) DateFormat.format("yyyy", date); // 2013


Calendar.YEAR  현재 년도를 가져온다.

Calendar.MONTH 현재 월을 가져온다. (1월은 0) 

Calendar.DATE  현재 월의 날짜를 가져온다. 

Calendar.WEEK_OF_YEAR 현재 년도의 몇째 주

Calendar.WEEK_OF_MONTH  현재 월의 몇째 주 

Calendar.DAY_OF_YEAR  현재 년도의 날짜 

Calendar.DAY_OF_MONTH  현재 월의 날짜 (DATE와 동일) 

Calendar.DAY_OF_WEEK  현재 요일 (일요일은 1, 토요일은 7)

Calendar.HOUR  현재 시간 (12시간제)

Calendar.HOUR_OF_DAY  현재 시간 (24시간제) 

Calendar.MINUTE  현재 분

Calendar.SECOND  현재 초 



Calendar -> date

Calendar cal = Calendar.getInstance(); 

Date date = cal.getTime(); 


 Date -> Calendar

Date d = new Date ( );

Calendar c = Calendar.getInstance ( );

c.setTime ( d );


calendar -> millisecond

    final Calendar calendar = Calendar.getInstance();

    calendar.set(Calendar.HOUR_OF_DAY, 0);

    calendar.set(Calendar.MINUTE, 0);

    calendar.set(Calendar.SECOND, 0);

    calendar.set(Calendar.MILLISECOND, 0);

    calendar.getTimeInMillis();


 millisecond -> calendar 

Calendar calendar = Calendar.getInstance();

calendar.setTimeInMillis(timeStamp);


int mYear = calendar.get(Calendar.YEAR);

int mMonth = calendar.get(Calendar.MONTH);

int mDay = calendar.get(Calendar.DAY_OF_MONTH);


 date -> millisecond 

long milli = date.getTime();


millisecond-> date

long time = System.currentTimeMillis ( );

Date date = new Date ( time );






ImageView

res/layout/activity_main.xml

<ImageView
android:id="@+id/main_image_view"
android:src="@drawable/ic_launcher_background"
android:tint="@color/colorPrimary"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<!--
scaleType = (view의 크기보다 이미지의 크기가 크거나 작을때 어떻게 처리할 지 설정){
CENTER = 뷰의 중앙에 이미지를 배치하고 확대/축소하지 않음
CENTER_CROP = 이미지를 뷰의 크기와 동일하거나 또는 조금 더 크게 확대/축소함(이미지 가로/세로 비율 유지)(가로세로 비율 키울때 ImageView에 다찼을때 나머지를 자름)
CENTER_INSIDE = 이미지를 뷰의 크기와 동일하거나 또는 조금 더 작게 확대/축소함(이미지 가로/세로 비율 유지)(이미지가 클때 ImageView안으로 들어가게 )(이미지작았을땐해당안됨)
(FIT은 작으면 크게 크면 작게 해줌)
FIT_CENTER = 가운데 배치 후 대상 뷰까지의 확대/축소 비율을 계산하는 속성(Matrix.ScaleToFit.CENTER)을 이용해 이미지를 확대/축소함(자주씀)
FIT_END = 우하단 배치 후 대상 뷰까지의 확대/축소 비율을 계산하는 속성(Matrix.ScaleToFit.END)을 이용해 이미지를 확대/축소함
FIT_START = 좌상단 배치 후 대상 뷰까지의 확대/축소 비율을 계산하는 속성(Matrix.ScaleToFit.START)을 이용해 이미지를 확대/축소함
FIT_XY = 가로와 세로에 대하여 각각 확대/축소 비율을 계산하는 속성(Matrix.ScaleToFit.FILL)을 이용하여 이미지를 확대/축소하므로 뷰의 가로와 세로의 크기를 정확히 맞춤(잘 안씀 이미지깨져서)
MATRIX = 이미지가 그려질 때 Matrix 객체를 이용해 확대/축소함
}

tint,tintMode = 이미지 위에 특정한 색을 입힐때 사용
maxWidth,maxHeight = view의 최대크기 설정
-->


drawable resource file 정보

color = color를 이용해 만든 이미지(ColorDrawable)
<color xmlns:android="http://schemas.android.com/apk/res/android" android:color="#ffff0000"/>



insert = 내부 여백을 갖도록 만든 이미지 (InsetDrawable)
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/r1"
android:insetLeft="10dp"
android:insetRight="10dp"
android:insetTop="10dp"
android:insetBottom="10dp"/>



layer-list = 여러 개의 이미지를 합쳐서 만든 이미지(LayerListDrawable)
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:opacity="translucent">
<item
android:id="@+id/drawable1"
android:drawable="@drawable/r1"
/>
<item
android:id="@+id/drawable2"
android:drawable="@drawable/r2"
android:top="30dp"
android:left="30dp"
android:right="30dp"
android:bottom="30dp" />
<item android:drawable="@drawable/a2"
android:top="60dp" android:left="60dp"/>
</layer-list>



transition = 두 이미지 사이에 fade 전환효과를 구현한 이미지(transitionDrawable)
<transition xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/r1"/>
<item android:drawable="@drawable/r2"/>
</transition>

ImageButton button = (ImageButton)findViewById(R.id.button);
TransitionDrawable drawable = (TransitionDrawable)button.getDrawable();
drawable.startTransition(500)//0.5초후 변환




selector = 상태에 따라 다른 이미지가 나타나도록 만든 이미지(stateListDrawable)
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/a1"/>
<item android:state_focused="true" android:drawable="@drawable/a1"/>
<item android:drawable="@drawable/a1"/>
</selector>




level-list = Level에 따라 다른 이미지를 보여주는 이미지(LevelListDrawable)
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:minLevel="0" android:maxLevel="2499" android:drawable="@drawable/a1"/>
<item android:minLevel="2500" android:maxLevel="4999" android:drawable="@drawable/a2"/>
<item android:minLevel="5000" android:maxLevel="7499" android:drawable="@drawable/a3"/>
<item android:minLevel="7500" android:maxLevel="10000" android:drawable="@drawable/a4"/>
</level-list>

ImageView.setImageLevel(10);





clip = 이미지를 자르는 이미지(ClipDrawable)
<clip xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/r1"
android:clipOrientation="horizontal"
android:gravity="left"/>

ImageView에서 ClipDrawable drawable = iv.getDrawable();로 가져와서 drawable.setLevel(level)cliping 적용.(level0~10000)




rotate= 이미지를 돌린다 (RotateDrawable)
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/ic_launcher_foreground"
android:fromDegrees="45" />//각도 설정 level=0이면(각도의 시작점) (각도는 45도부터 시계반향이 시작점)
android:toDegrees="180"////level10000이면(각도의 끝점)
android:pivotX="50%"
android:pivotY="50%"/>//중심축 설정




scale= 이미지를 확대,축소한다 (ScaleDrawable)
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/r1"
android:scaleWidth="80%"
android:scaleHeight="80%"
android:scaleGravity="center_vertical|center_horizontal"/>




animation-list = 이미지들을 연결하여 애니메이션을 구현한 이미지(animationDrawable)
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false">//oneshow=true면 모든게 한번에 보임
<item android:drawable="@drawable/a1" android:duration="50"/>//단위millisecond//1000 =1
<item android:drawable="@drawable/a2" android:duration="50"/>
<item android:drawable="@drawable/a3" android:duration="50"/>
<item android:drawable="@drawable/a4" android:duration="50"/>
<item android:drawable="@drawable/a5" android:duration="50"/>
<item android:drawable="@drawable/a6" android:duration="50"/>
<item android:drawable="@drawable/a7" android:duration="50"/>
</animation-list>




shape = xml로 도형의 모양을 만든 이미지(GradientDrawable)
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line">
<size
android:width="100dp"
android:height="100dp"
/>
<stroke
android:color="#ff0000ff"
android:width="2dp"
android:dashWidth="5dp" 줄사이즈 설정
android:dashGap="2dp" /> 줄간격 사이즈설정
</shape>

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">네모
<size
android:width="100dp"
android:height="100dp"/>
<corners (끝에 코너주기)
android:topLeftRadius="5dp"
android:topRightRadius="5dp"
android:bottomLeftRadius="5dp"
android:bottomRightRadius="5dp"/>
<solid android:color="@color/colorPrimary"/>//안에 채움
<stroke(끝에 줄)
android:width="1dp"
android:color="@color/colorAccent"
android:dashWidth="5dp"
android:dashGap="2dp"/>
</shape>


<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
<size
android:width="100dp"
android:height="100dp"/>
<solid
android:color="@color/colorPrimary"/>
<stroke
android:width="2dp"
android:color="@color/colorPrimaryDark"/>
</shape>

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="ring" 도넛모양
android:innerRadiusRatio="6"
android:thicknessRatio="10"
android:useLevel="false">//truesetLevel에 따라 채움 가능
<size
android:height="100dp"
android:width="100dp"/>
<solid
android:color="@color/colorPrimary"/>
<stroke
android:width="2dp"
android:color="@color/colorAccent"
android:dashGap="2dp"
android:dashWidth="2dp"/>
</shape>

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<gradient
android:type="linear" 점진적으로 바뀜
android:startColor="@color/colorAccent"
android:centerColor="@color/colorPrimary"
android:endColor="@color/colorPrimaryDark"
android:centerX="100%"
android:centerY="100%"
android:angle="90"/>
<gradient
android:type="radial" 원형모양으로 바뀜
android:startColor="@color/colorAccent"
android:centerColor="@color/colorPrimary"
android:endColor="@color/colorPrimaryDark"
android:centerX="50%"
android:centerY="50%"
android:gradientRadius="500"/>
<gradient
android:type="sweep" 시계방향으로 바뀜
android:startColor="@color/colorAccent"
android:centerColor="@color/colorPrimary"
android:endColor="@color/colorPrimaryDark"
android:centerX="50%"
android:centerY="50%" />
</shape>




반응형

'android > study' 카테고리의 다른 글

toolbar  (0) 2022.01.24
layout  (0) 2018.04.08

+ Recent posts