안녕세계

[안드로이드] Support Library 추가 본문

[안드로이드] Support Library 추가

Junhong Kim 2018. 3. 8. 09:48
728x90
반응형

Project/build.gradle (Module: App)

dependencies {
/* .. */


compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
}


위 두가지를 추가하고 Sync를 맞춰주시면,

아래와 같이 CoordinatorLayoutBottomNavigationView 같은 컴포넌트를 사용하실 수 있습니다!

(최신 버전이 아닐 경우 Warning이 뜨는데, [command + enter] 를 입력하셔서 최신 버전으로 추가하실 수 있습니다.)


<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">

<data>

<variable
name="activity"
type="com.kimjunhong.allthatbank.MainActivity" />
</data>

<android.support.design.widget.CoordinatorLayout 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="com.kimjunhong.allthatbank.MainActivity">

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="@{activity::onButtonClick}"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent" />

<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_navigation_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:itemBackground="@color/colorPrimary"
app:itemIconTint="@color/colorAccent"
app:itemTextColor="@color/colorAccent"
app:layout_anchor="@+id/viewPager"
app:layout_anchorGravity="bottom"
app:menu="@menu/bottom_navigation_view" />
</android.support.design.widget.CoordinatorLayout>
</layout>


728x90
반응형
Comments