728x90
반응형
package kr.co.eoapps.test_module;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.Button;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
public class Test2 extends BottomSheetDialogFragment {
private BottomSheetListener mListener;
@Override
public int getTheme() {
return R.style.CustomBottomSheetDialog;
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.activity_test2, container, false);
/* Button button1 = v.findViewById(R.id.button1);
Button button2 = v.findViewById(R.id.button2);
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mListener.onButtonClicked("Button 1 clicked");
dismiss();
}
});
button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mListener.onButtonClicked("Button 2 clicked");
dismiss();
}
});*/
return v;
}
public interface BottomSheetListener {
void onButtonClicked(String text);
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
try {
mListener = (BottomSheetListener) context;
} catch (ClassCastException e) {
throw new ClassCastException(context.toString()
+ " must implement BottomSheetListener");
}
}
}
* 등장하는 액티비티의 모서리를 둥글게 하고 싶다면,
res / value / themes.xml
<style name="CustomBottomSheetDialog" parent="@style/ThemeOverlay.MaterialComponents.BottomSheetDialog">
<item name="bottomSheetStyle">@style/CustomBottomSheet</item>
</style>
<style name="CustomBottomSheet" parent="Widget.MaterialComponents.BottomSheet">
<item name="shapeAppearanceOverlay">@style/CustomShapeAppearanceBottomSheetDialog</item>
</style>
<style name="CustomShapeAppearanceBottomSheetDialog" parent="">
<item name="cornerFamily">rounded</item>
<item name="cornerSizeTopRight">20dp</item>
<item name="cornerSizeTopLeft">20dp</item>
<item name="cornerSizeBottomRight">0dp</item>
<item name="cornerSizeBottomLeft">0dp</item>
</style>
후
getTheme 에서 셋팅.!
codinginflow.com/tutorials/android/modal-bottom-sheet
Modal Bottom Sheet - Coding in Flow
In this tutorial we will learn, how to create a modal bottom sheet, by subclassing BottomSheetDialogFragment. Our sheet will have a custom layout and it will be able to communicate back to the underlying activity over an interface. Check out the PERSISTENT
codinginflow.com
드래그를 원하는 경우
Persistent BottomSheet drag 참고
[Android] BottomSheet
개요 화면 하단에서 어느 정도 높이로 고정이 되어있지만 손 드래그에 따라 올라가기도, 내려가기도, 또 사라지기도 하는 뷰를 만들고 싶을 때 사용할 수 있는 안드로이드 컴포넌트이다. 종류
dev-eunji.tistory.com
728x90
반응형
'Android' 카테고리의 다른 글
Android 애니메이션 관련 (0) | 2021.02.17 |
---|---|
android ViewPager2 : 안드로이드 뷰 페이저 (0) | 2021.02.06 |
Android 커스텀 다이얼로그 (0) | 2021.01.21 |
Android SNS공유 ( 트위터) (0) | 2021.01.19 |
Android AAR 만들기 ( 라이브러리 만들기 ) (0) | 2021.01.19 |