我有一个Activity,其布局如下:
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/top_menu_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="16dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
// ICONS
</RelativeLayout>
<FrameLayout
android:id="@+id/temperatura_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="184dp"
android:layout_centerHorizontal="true">
<com.github.pavlospt.CircleView xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/reading_value"
android:layout_width="192dp"
android:layout_height="192dp"
android:layout_gravity="center"
/>
</FrameLayout>
<ImageView
android:id="@+id/add_item_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/bottomBar"
android:layout_centerHorizontal="true"
android:padding="12dp"
android:layout_marginTop="36dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:focusable="true"
android:scaleType="center"
app:srcCompat="@drawable/ic_add_item_black_24px"
android:contentDescription="@string/add_item_btn_description" />
<com.roughike.bottombar.BottomBar
android:id="@+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
app:bb_behavior="iconsOnly"
app:bb_tabXmlResource="@xml/bottom_navbar" />
</RelativeLayout>
add_item_btn
有一个点击事件,该事件创建一个全屏DialogFragment
来插入项目信息并将其添加到本地数据库中。以下代码显示我如何创建DialogFragment
:
FragmentManager fragmentManager = getSupportFragmentManager();
InsertItemDialogFragment fragment = new InsertItemDialogFragment();
FragmentTransaction transaction = fragmentManager.beginTransaction();
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
transaction.add(android.R.id.content, fragment).addToBackStack(null).commit();
问题是,当我使用
dismiss()
关闭创建的片段时,活动布局会拉伸,在屏幕按钮栏的底部栏被覆盖一半(请参见图像)。
我尝试更改FragmentTransaction
(从android.R.id.content
更改为R.id.main_content
,其中main_content
是根 RelativeLayout
的ID),但没有成功。我还尝试使用两种不同的Material Design底部导航栏实现,但两者都有相同的行为。