ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [안드로이드 스튜디오] XML 파일로 사용자 인터페이스 작성
    프로그래밍/XML | JAVA 2024. 3. 11. 15:53

    1. new project -> empty 뭐시기 -> 제목 : button 뭐시기

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
        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">
    
        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_marginStart="16dp"
            android:layout_marginTop="16dp"
            android:text="첫번째 버튼"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"></Button>
    
        <Button
            android:id="@+id/button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="16dp"
            android:layout_marginTop="16dp"
            android:text="두번째 버튼"
            app:layout_constraintStart_toStartOf="@+id/button1"
            app:layout_constraintTop_toBottomOf="@+id/button1"></Button>
    </LinearLayout>
    <?xml version="1.0" encoding="utf-8"?>
    <androidx.appcompat.widget.LinearLayoutCompat
        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"
        android:orientation="vertical"
        tools:context=".MainActivity">
    
        <Button
            android:id="@+id/button1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="첫번째 버튼">
        </Button>
    
        <Button
            android:id="@+id/button2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="두번째 버튼">
        </Button>
    </androidx.appcompat.widget.LinearLayoutCompat>
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
        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"
        android:orientation="vertical"
        android:background="#aaff0000"
        tools:context=".MainActivity">
    
        <Button
            android:id="@+id/button1"
            android:layout_width="250dp"
            android:layout_height="60dp"
            android:layout_margin="30dp"
            android:padding="10dp"
            android:background="#8BC34A"
            android:text="마진 30dp, 패딩 10dp">
        </Button>
    
        <Button
            android:id="@+id/button2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#aa223400"
            android:text="두번째 버튼"
            android:enabled="false">
        </Button>
    
        <Button
            android:id="@+id/button3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="세번째 버튼">
        </Button>
    
        <Button
            android:id="@+id/button4"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:rotation="45"
            android:text="네번째 버튼">
        </Button>
    </LinearLayout>
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
        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"
        android:orientation="vertical"
        tools:context=".MainActivity">
    
        <Button
            android:id="@+id/button1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:backgroundTint="#ffff00"
            android:text="첫번째 버튼"
            android:textColor="#00aa00"
            android:textSize="30dp">
        </Button>
    
        <Button
            android:id="@+id/button2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#aa223400"
            android:text="두번째 버튼">
        </Button>
    
        <TextView
            android:id="@+id/textView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="30dp"
            android:text="나는 텍스트뷰입니다."
            android:textColor="#ff0000"
            android:gravity="center">
        </TextView>
    
    </LinearLayout>

     

Designed by Tistory.