隐藏操作栏会导致RelativeLayout中底部对齐的项目跳转 [英] Hiding the action bar causes bottom aligned item in RelativeLayout to jump

查看:63
本文介绍了隐藏操作栏会导致RelativeLayout中底部对齐的项目跳转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

i have RelativeLayout with a view that is aligned to the parent bottom. when i call actionBar.hide() the view slides up as the action bar slides up, then once the action bar has fully disappeared, the view jumps back to the bottom.

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

how do i prevent this from happening? i want the view to stay attached to the bottom as the action bar slides up.

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

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

the tabs are what are bottom aligned. (the grey stuff you see above is a different fragment being loaded so ignore that)

代码:

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();
    }
}

R.layout.fragment_main:

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>

推荐答案

以您的AppTheme样式设置操作栏叠加模式:

Set action bar overlay mode in your AppTheme style:

<item name="android:windowActionBarOverlay">true</item>
<!-- Support library compatibility -->  
<item name="windowActionBarOverlay">true</item>

(更多信息)

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

and, if you need, set padding or margin in your layout file like this: ?android:attr/actionBarSize

这篇关于隐藏操作栏会导致RelativeLayout中底部对齐的项目跳转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆