[ Do it! ] #1. 도전! - 새 프로젝트 아래쪽에 두 개의 버튼 추가하기

ma.caron_g·2022년 2월 6일
0

Do it! - Android Studio

목록 보기
2/18
post-thumbnail

[ 📄 문 제 ]

새로운 프로젝트를 만들고 아래쪽에 두 개의 버튼이 보이는 화면을 만들어보세요.

  • 초급 과정
    -화면 아래쪽에 버튼 추가하기
  • 프로젝트 소스
    -DoitMission-01

[ 📚 설 명 ]

  1. 제약 레이아웃을 사용해 화면을 구성합니다
  2. 화면의 아래쪽 가이드라인을 배치합니다
  3. 가이드라인의 위쪽에 버튼을 추가한 후 가이드라인과 연결합니다.
    그리고 적절한 간격으로 띄워줍니다.
  4. 가이드라인의 위쪽에 버튼을 하나 더 추가한 후 이전에 추가했던 버튼 및 가이드라인과 연결합니다.
    그리고 적절하게 띄워줍니다.

[ 💻 코 드 ]

//activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">


    <androidx.constraintlayout.widget.Guideline
        android:id="@+id/guideline2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintGuide_begin="650dp"/>

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="16dp"
        android:text="Button 1"
        app:layout_constraintBottom_toTopOf="@+id/guideline2"
        app:layout_constraintEnd_toStartOf="@+id/button2"
        app:layout_constraintHorizontal_bias="0.652"
        app:layout_constraintStart_toStartOf="parent" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="80dp"
        android:layout_marginBottom="16dp"
        android:text="Button 2"
        app:layout_constraintBottom_toTopOf="@+id/guideline2"
        app:layout_constraintEnd_toEndOf="parent" />
        
</androidx.constraintlayout.widget.ConstraintLayout>

[ 🖋 디자인 ]

profile
다른 사람이 만든 것을 소비하는 활동보다, 내가 생산적인 활동을 하는 시간이 더 많도록 생활화 하자.

0개의 댓글