<Android> 5. ConstraintLayout, FrameLayout
by BFine반응형
1. ConstraintLayout
ConstraintLayout: 제약조건을 가진 레이아웃
View를 생성할때 4구역에 제약 조건을 줄수있는 동그라미가 생긴다. ( 다른 뷰, 컨테이너 적용가능)
주의할점은 Constraint를 하나라도 주지 않을 경우 오류가 발생한다
오른쪽 화면을 보면 +가 4군데 생기는 것을 볼 수 있다. ( 모든 뷰에 동일 적용 )
자석모양의 Autoconnect은 자동으로 제약조건을 설정해준다.
자석옆에서 7번째에 있는 아이콘은 guide line을 설정할 수 있게 한다.
2. FrameLayout
FrameLayout : 뷰들을 중첩하여 가장 나중에 만든 뷰를 맨앞에 보여준다. 화면전환할때 사용한다.
FrameLayout을 활용한 화면전환
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 | public class MainActivity extends AppCompatActivity { TextView textView,textView2,textView3; static int count=0; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); textView =findViewById(R.id.textView); // View의 id값을 가져온다 textView2 =findViewById(R.id.textView2); textView3 =findViewById(R.id.textView3); } public void nextColor(View view){ count++; if(count==1){ textView.setVisibility(view.VISIBLE); // visibility 속성을 변경 }else if(count==2){ textView2.setVisibility(view.VISIBLE); }else{ count=3; textView3.setVisibility(view.VISIBLE); } } public void beforeColor(View view){ count--; if(count==2){ textView3.setVisibility(view.INVISIBLE); }else if(count==1){ textView2.setVisibility(view.INVISIBLE); }else{ count=0; textView.setVisibility(view.INVISIBLE); } } } | cs |
실행
3. Link to your smart phone
안드로이드 스튜디오와 스마트폰 연결이 안될때
개발자 옵션 USB 디버깅이 설정 되었는 지 확인
※ 컴퓨터와 USB 연결이 되더라도 해당 스마트폰의 연결 USB 드라이버 설치 필수
안드로이드 Run을 눌렀을 때 가상 device위에 connected device에 핸드폰이 보이면 연결됨
API 버전이 맞지 않을 경우에도 connected device에 표시됨
반응형
블로그의 정보
57개월 BackEnd
BFine