Вы должны добавить значок ящика в bottomAppbar
, затем использовать bottomsheet
для ящика.
для вашего ящика у вас есть два варианта:
1 - перейдите по стандартам Google и добавьте элементы ящика в папку меню (кажется, вам это не нужно)
2 - замените фрагмент на нижнем листе, чтобы вы могли настроить свойфрагментируйте и делайте все что угодно
------------------- замените фрагмент в нижнем листе -------------
ваша активность.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:custom="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layoutDirection="ltr"
android:background="@color/white"
android:orientation="vertical">
<FrameLayout
android:id="@+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:elevation="6dp"
android:visibility="visible"
app:layout_behavior="@string/bottom_sheet_behavior">
<FrameLayout
android:id="@+id/menu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" />
</FrameLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
ваша активность.java
public class Activity extends AppCompatActivity implements
FragmentNavigation.OnFragmentInteractionListener {
private CoordinatorLayout coordinatorLayout;
private View bottomSheet;
private BottomSheetBehavior<View> behavior;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity);
FrameLayout bottomSheetLayout = (FrameLayout)
findViewById(R.id.menu);
FragmentNavigation fragmentNavigation = new FragmentNavigation();
androidx.fragment.app.FragmentTransaction fragmentTransaction =
getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(bottomSheetLayout.getId(),
fragmentNavigation, "k");
fragmentTransaction.commit();
coordinatorLayout = (CoordinatorLayout)
findViewById(R.id.main_content);
bottomSheet = coordinatorLayout.findViewById(R.id.bottom_sheet);
behavior = BottomSheetBehavior.from(bottomSheet);
}
@Override
public void onFragmentInteraction(Uri uri) {
}
}
навигация по вашему фрагменту
public class FragmentNavigation extends androidx.fragment.app.Fragment {
private String descriptions;
public FragmentNavigation () {
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO Auto-generated method stub
View view = inflater.inflate(R.layout.fragment_navigation, container, false);
return view;
}
}
ваш фрагмент_navigation.xml
<?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:custom="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical">
<TextView
android:id="@+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:elevation="6dp"
android:visibility="visible"
android:text="here is the navigation menu"
app:layout_behavior="@string/bottom_sheet_behavior"/>
</LinearLayout>