이번 시간부터 TabLayout을 직접 만들어 애니메이션까지
넣어보는 방법을 알아보겠습니다.
이번 포스팅은 화면 구성을 해보겠습니다.
( res -> value -> themes)
parent부분을 noActionBar로 변경하면 됩니다.
<style name="Theme.MyApplication" parent="Theme.AppCompat.Light.NoActionBar">
res -> drawable 클릭 -> 마우스 오른쪽 -> new -> Drawable Resource File
탭 전체 배경색상용
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#1AFFFFFF"/>
<corners android:radius="100dp"/>
</shape>
탭 선택한 배경색상용
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FFFFFF"/>
<corners android:radius="100dp"/>
</shape>
- 설명 -
1. LinearLayout을 메인으로 각 아이템은 텍스트뷰로
구성했습니다.
2. 선택된 아이템은 흰색 바탕에 검은색 글씨로 보입니다.
3. 선택되지 않은 아이템은 투명 바탕에 흰색 글씨로 보입니다.
4. FragmentContainerView에는 탭 선택에 따라 각 프래그먼트 화면이
보일 것입니다.
<?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">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/holo_blue_dark">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="3"
android:background="@drawable/round_back_white10_100"
android:layout_margin="20dp">
<TextView
android:id="@+id/tabItem1"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_weight="1"
android:gravity="center"
android:text="Tab Item 1"
android:textStyle="bold"
android:background="@drawable/round_back_white100"
android:textColor="#000000"/>
<TextView
android:id="@+id/tabItem2"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_weight="1"
android:gravity="center"
android:text="Tab Item 2"
android:textColor="#80FFFFFF"/>
<TextView
android:id="@+id/tabItem3"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_weight="1"
android:gravity="center"
android:text="Tab Item 3"
android:textColor="#80FFFFFF"/>
</LinearLayout>
</RelativeLayout>
<androidx.fragment.app.FragmentContainerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/fragmentContainer"/>
</LinearLayout>
2022.04.07 - [안드로이드] - [안드로이드] 코드(MainActivity)에서 배경 색상 바꾸는 다양한 방법
[안드로이드] 코드(MainActivity) 에서 배경색상 바꾸는 다양한 방법
이번 시간에는 코드에서 레이아웃이나 텍스트뷰들의 배경 색상을 바꾸는 다양한 방법을 알아보겠습니다. 목차 1. 실행 화면 2. 메인 화면 구성 activity_main.xml 3. 메인 코드 구현 MainActivity.java 1. 실
aries574.tistory.com
2022.04.06 - [안드로이드] - [안드로이드] RecyclerView 다중 선택하는 방법
[안드로이드] RecyclerView 다중선택 하는 방법
이번 시간에는 RecyclerView로 리스트를 생성하고, 다중 선택을 하는 방법을 알아보겠습니다. 1. 실행 화면 2. 아이템 클래스 만들기 3. 아이템 화면 만들기 4. 아이템 어뎁터 만들기 5. 메인 화면 구성
aries574.tistory.com
2022.04.02 - [안드로이드] - [안드로이드] 같은 그림 찾기 게임 만드는 방법 part1 - 화면 구성
[안드로이드] 같은 그림 찾기 게임 만드는 방법 part1 - 화면구성
앞으로 같은 그림 찾기 게임을 만들어 보겠습니다. 이번 시간에는 화면 구성을 해보겠습니다. 이 게임은 8장의 카드가 있고, 2장의 카드를 뒤집어서 같은 그림이면 성공, 틀리면 맞을 때까지 하
aries574.tistory.com
[안드로이드] Tab Custom Animation part3 - 탭 애니메이션 적용 (0) | 2022.04.10 |
---|---|
[안드로이드] Tab Custom Animation part2 - 탭 기능 구현 (0) | 2022.04.09 |
[안드로이드] 코드(MainActivity) 에서 배경색상 바꾸는 다양한 방법 (0) | 2022.04.07 |
[안드로이드] RecyclerView 다중선택 하는 방법 (0) | 2022.04.06 |
[안드로이드] 같은 그림 찾기 게임 만드는 방법 part4 - 비교&완료 (0) | 2022.04.05 |
댓글 영역