Custom Bottom Sheet in Android

 

//--------------------------------------------Code Detail and Working---------------------------------------------------------

1 Step bottom sheet Craete XML cell side

//============================java Code Start =========================================

<TextView
   
android:layout_width="match_parent"
   
android:layout_height="wrap_content"
   
android:text="View"
   
android:gravity="center"
   
android:textSize="50dp"/>
<LinearLayout
   
android:padding="10dp"
   
android:layout_width="match_parent"
   
android:layout_height="wrap_content"
   
android:background="@drawable/edit_style"
   
android:orientation="horizontal"
   
android:id="@+id/txt_Recodings_click"
   
android:layout_margin="20dp">
    <ImageView
       
android:layout_width="wrap_content"
       
android:layout_height="wrap_content"
       
android:src="@drawable/recording_icon"/>
    <TextView
       
android:layout_width="match_parent"
       
android:layout_height="wrap_content"
       
android:text="Recordings"
       
android:gravity="center"
       
android:textSize="50dp"/>
</LinearLayout>
<LinearLayout
   
android:padding="10dp"
   
android:layout_width="match_parent"
   
android:layout_height="wrap_content"
   
android:background="@drawable/edit_style"
   
android:id="@+id/txt_Schedule_click"
   
android:orientation="horizontal"
   
android:layout_margin="20dp">
    <ImageView
       
android:layout_width="wrap_content"
       
android:layout_height="wrap_content"
       
android:src="@drawable/work_timetable_icon"/>
    <TextView
       
android:layout_width="match_parent"
       
android:layout_height="wrap_content"
       
android:text="Schedule"
       
android:gravity="center"
       
android:textSize="50dp"/>
</LinearLayout>

=========================================End=========================================

//--------------------------------------------Code Detail and Working---------------------------------------------------------

2 Step bottom sheet Craete Drawable shape

//============================java Code Start =========================================

<shape android:shape="rectangle"  xmlns:android="http://schemas.android.com/apk/res/android">
        <solid
android:color="@color/white"/>
        <corners
android:topLeftRadius="30dp" android:bottomRightRadius="20dp"/>

</shape>

 

=========================================End=========================================

2 Step bottom sheet add theme folder Style

//============================java Code Start =========================================

<style name="BottomSheetStyle" parent="Theme.Design.BottomSheetDialog">
    <item
name="bottomSheetStyle">@style/Model</item>
</style>
<style
name="Model" parent="Widget.Design.BottomSheet.Modal">
    <item
name="android:background">@drawable/dialog_bg_teacher</item>
</style>

 

=========================================End=========================================

3 Step bottom sheet add theme Style

//============================java Code Start =========================================

View bottomsheet_teacher = getLayoutInflater().inflate(R.layout.bottomsheet_dialog_teacher,null);
BottomSheetDialog dialog = new BottomSheetDialog(getContext(),R.style.BottomSheetStyle);
bottomsheet_teacher.findViewById(R.id.txt_Recodings_click).setOnClickListener(new View.OnClickListener() {
   
@Override
   
public void onClick(View view) {
        Toast.makeText(getActivity()
, "dafds", Toast.LENGTH_SHORT).show();
   
}
})
;
dialog.setContentView(bottomsheet_teacher);
dialog.show();

=========================================End=========================================

 

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.