Windows에 Git을 먼저 설치하고 버전관리를 시작하려는 안드로이드 스튜디오 프로젝트에서 VCS-Enable Version Control Integration..을 누른다.

Git을 선택하고 확인

app을 우클릭 후 Git-Add 선택

Bitbucket에서 저장소를 만든다.

 

Readme를 포함하면 나중에 push할 때 오류가 나더라. 원인이 뭔지 몰라 해결하지 못했지만 강제로 push하려면 터미널에 아래 코드를 입력하면 된다.

$ git push -u origin +main

만들어진 저장소 주소(HTTPS)를 복사한다.

Git-Manage Remotes

 

아까 복사한 주소를 넣는다.

확인을 누른 후 커밋

안드로이드 스튜디오는 기본 브랜치 이름이 master로 되어 있다. 브랜치 명을 main으로 바꾸고 싶으면 push하기 전에 Git-Branches에 들어가 로컬 저장소 브랜치 명을 바꾼다.

이제 push해 보자.

Bitbucket에 push 완료!

FloatingActionButton의 색상을 변경하고 싶다!

 

app:backgroundTint : 버튼 색상

app:tint : 버튼 안의 아이콘 색상

app:rippleColor : 버튼을 눌렀을 때 퍼지는 이펙트 색상

 

<com.google.android.material.floatingactionbutton.FloatingActionButton
    android:id="@+id/floating_action_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_margin="16dp"
    android:contentDescription="@string/fab_content_desc"
    android:src="@drawable/ic_baseline_add_24"
    app:rippleColor="@color/purple_200"
    app:tint="@color/white"
    app:backgroundTint="@color/purple_500" />

 

layout 안의 뷰 여러 개를 percent에 따라 화면의 각 비율만큼 차지하게 하고 싶을 때 부모 layout에 따라 값을 지정하는 방법이 다르다.

Linearlayout과 Constraintlayout의 두 가지 경우를 살펴보자.

두 경우 모두 weight을 지정하려는 자식 view의 width나 height 값을 0dp로 설정해야 한다. 아래 코드에서는 layout_height 값을 0dp로 하고 비율을 9 : 1로 설정했다.

 

1. 부모가 LinearLayout일 때는 부모에 weightSum을 설정하고 자식에 layout_weight 값을 지정한다.

 

<?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:weightSum="10"
    tools:context=".MainActivity">

    <FrameLayout
        android:id="@+id/frame_layout"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="9" />

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottom_navigation"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_gravity="bottom"
        android:layout_weight="1"
        app:labelVisibilityMode="unlabeled"
        app:menu="@menu/bottom_navigation_menu" />
</LinearLayout>

 

2. 부모가 Constraintlayout일 때는 자식의 layout_constraintHeight_percent값을 지정한다. width일 때도 마찬가지. percent 값은 소수점으로 입력한다. (10% = 0.1로 입력)

<?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"
    android:orientation="vertical"
    tools:context=".MainActivity">

    <FrameLayout
        android:id="@+id/frame_layout"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHeight_percent="0.9"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottom_navigation"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_gravity="bottom"
        app:labelVisibilityMode="unlabeled"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHeight_percent="0.1"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/frame_layout"
        app:menu="@menu/bottom_navigation_menu" />

</androidx.constraintlayout.widget.ConstraintLayout>

버튼을 <Button>으로 했더니 foreground 수정은 반영이 되는데 background에 이미지를 넣던 색을 넣던 수정이 안되는 현상이 있었다. 간단하게 태그를 <androidx.appcompat.widget.AppCompatButton>로 수정해서 해결함.

 

    //<Button />
    <androidx.appcompat.widget.AppCompatButton
        android:id="@+id/btn_signin_google"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:layout_margin="16dp"
        android:background="@drawable/btn_google_signin_light_normal_hdpi"
        android:text="@string/signin_google"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/tv_appTitle" />

+ Recent posts