728x90
Gradle 추가
implementation 'com.ramotion.circlemenu:circle-menu:0.3.2'
res\values\buttons.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<array name="icons">
<item>@drawable/ic_home_white_24dp</item>
<item>@drawable/ic_search_white_24dp</item>
<item>@drawable/ic_notifications_white_24dp</item>
<item>@drawable/ic_settings_white_24dp</item>
<item>@drawable/ic_place_white_24dp</item>
</array>
<array name="colors">
<item>@android:color/holo_blue_light</item>
<item>@android:color/holo_green_dark</item>
<item>@android:color/holo_red_light</item>
<item>@android:color/holo_purple</item>
<item>@android:color/holo_orange_light</item>
</array>
</resources>
MainActivity.java
import android.os.Bundle;
import android.util.Log;
import com.ramotion.circlemenu.CircleMenuView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final CircleMenuView menu = findViewById(R.id.circle_menu);
menu.setEventListener(new CircleMenuView.EventListener() {
@Override
public void onMenuOpenAnimationStart(@NonNull CircleMenuView view) {
Log.d("D", "onMenuOpenAnimationStart");
}
@Override
public void onMenuOpenAnimationEnd(@NonNull CircleMenuView view) {
Log.d("D", "onMenuOpenAnimationEnd");
}
@Override
public void onMenuCloseAnimationStart(@NonNull CircleMenuView view) {
Log.d("D", "onMenuCloseAnimationStart");
}
@Override
public void onMenuCloseAnimationEnd(@NonNull CircleMenuView view) {
Log.d("D", "onMenuCloseAnimationEnd");
}
@Override
public void onButtonClickAnimationStart(@NonNull CircleMenuView view, int index) {
Log.d("D", "onButtonClickAnimationStart| index: " + index);
}
@Override
public void onButtonClickAnimationEnd(@NonNull CircleMenuView view, int index) {
Log.d("D", "onButtonClickAnimationEnd| index: " + index);
}
@Override
public boolean onButtonLongClick(@NonNull CircleMenuView view, int index) {
Log.d("D", "onButtonLongClick| index: " + index);
return true;
}
@Override
public void onButtonLongClickAnimationStart(@NonNull CircleMenuView view, int index) {
Log.d("D", "onButtonLongClickAnimationStart| index: " + index);
}
@Override
public void onButtonLongClickAnimationEnd(@NonNull CircleMenuView view, int index) {
Log.d("D", "onButtonLongClickAnimationEnd| index: " + index);
}
});
}
}
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="com.ramotion.circlemenu.example.simple.MainActivity">
<com.ramotion.circlemenu.CircleMenuView
android:id="@+id/circle_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:button_colors="@array/colors"
app:button_icons="@array/icons"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
buttons.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<array name="icons">
<item>@drawable/ic_home_white_24dp</item>
<item>@drawable/ic_search_white_24dp</item>
<item>@drawable/ic_notifications_white_24dp</item>
<item>@drawable/ic_settings_white_24dp</item>
<item>@drawable/ic_place_white_24dp</item>
</array>
<array name="colors">
<item>@android:color/holo_blue_light</item>
<item>@android:color/holo_green_dark</item>
<item>@android:color/holo_red_light</item>
<item>@android:color/holo_purple</item>
<item>@android:color/holo_orange_light</item>
</array>
</resources>
icon 버튼은 다운 받아서 drawable 아래 넣어주시면 됩니다.
'안드로이드 코틀린' 카테고리의 다른 글
[Kotlin][Android] 디바이스 전체 화면 길이 구하기 (0) | 2022.06.18 |
---|---|
[Kotlin][Android] Lambda 사용해서 계산 기능 만들기 (0) | 2022.06.13 |
[Kotlin][Android] 오늘 요일 알아오기 (0) | 2022.06.11 |
[Kotlin][Android] ViewModel 공유하기 (0) | 2022.06.10 |
[Kotlin][Android] 도움말 (0) | 2022.06.07 |