隐藏操作栏会导致RelativeLayout中底部对齐的项目跳转

fso*_*ety 5 android relativelayout android-actionbar

我有RelativeLayout一个与父底部对齐的视图。当我调用actionBar.hide()该视图时,随着操作栏向上滑动,视图也随之向上滑动,然后,一旦操作栏完全消失,视图就会跳回到底部。

我如何防止这种情况发生?我希望视图在操作栏向上滑动时保持在底部。

无法嵌入图片,因此这是一个链接

标签是底部对齐的。(您在上面看到的灰色内容是一个正在加载的不同片段,因此请忽略它)

码:

public class MainFragment extends Fragment {
    public View onCreateView(...) {
        return inflater.inflate(R.layout.fragment_main);
    }
    public void onResume() {
        super.onResume();
        getActivity().getActionBar().hide();
    }
    public void onPause() {
        super.onPause();
        getActivity().getActionBar().show();
    }
}
Run Code Online (Sandbox Code Playgroud)

R.layout.fragment_main:

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:text="test" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

igo*_*_rb 7

在您的 AppTheme 样式中设置操作栏覆盖模式:

<item name="android:windowActionBarOverlay">true</item>
<!-- Support library compatibility -->  
<item name="windowActionBarOverlay">true</item>
Run Code Online (Sandbox Code Playgroud)

(更多信息)

并且,如果您需要,在您的布局文件中设置填充或边距,如下所示: ?android:attr/actionBarSize