【发布时间】:2020-04-08 19:35:43
【问题描述】:
我想在显示小吃店时将按钮向上移动,这样就不会隐藏它们。我已经尝试过堆栈溢出的不同解决方案,但我无法找到解决方案。这是我的布局文件:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
android:paddingLeft="0dp"
android:paddingRight="0dp" >
<include
android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
layout="@layout/fragment_expiry_dates_list_header" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/products_list"
android:name="com.example.expirydate.ui.main.ExpiryDatesFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/header"
android:layout_above="@id/buttonNewOrOpened"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:layout_marginBottom="3dp"
app:layoutManager="LinearLayoutManager"
tools:context=".expirydatefragment.ExpiryDatesFragment"
tools:listitem="@layout/fragment_expiry_dates_list_item" />
<Button
android:id="@+id/buttonNewOrOpened"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerInParent="false"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:enabled="false"
android:text="New" />
<Button
android:id="@+id/buttonUsed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toEndOf="@id/buttonNewOrOpened"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:enabled="false"
android:text="Used" />
<ImageButton
android:id="@+id/buttonScanner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="center"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:layout_toStartOf="@id/buttonAdd"
android:background="@drawable/roundcorner"
android:padding="8dp"
android:src="@android:drawable/ic_menu_gallery"
android:contentDescription="scan product" />
<ImageButton
android:id="@+id/buttonAdd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_gravity="center"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:padding="8dp"
android:background="@drawable/roundcorner"
android:src="@android:drawable/ic_input_add"
android:contentDescription="add product" />
</RelativeLayout>
我想做的是移动小吃店上方底部的这 4 个按钮。显示小吃店的代码:
Snackbar snackbar = Snackbar.make(getActivity().findViewById(android.R.id.content), "msg", Snackbar.LENGTH_SHORT);
snackbar.setAction("Undo", v -> {});
snackbar.show();
我尝试了几种解决方案,添加了我自己的 layout_behavior 或添加了 app:insetEdges="bottom",但没有任何效果。
【问题讨论】:
标签: android android-relativelayout android-snackbar