FitWindowsLinearLayout

FitWindowsLinearLayout

本文介绍了LinearLayout和FitWindowsLinearLayout有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

在创建Layout,时,我跨过FitWindowsLinearLayout,但似乎无法理解LinearLayoutFitWindowsLinearLayout之间的区别.

While creating a Layout, I cam across FitWindowsLinearLayout but can't seem to understand the difference between LinearLayout and FitWindowsLinearLayout.

那么,我们什么时候应该使用FitWindowsLinearLayout?

So, when should we use FitWindowsLinearLayout?

FitWindowsLinearLayout

推荐答案

首先,您可以看到它是@hide 注释,这意味着它没有暴露给公共API .这意味着您不应该使用它.

First, as you can see it is annotated with @hide, which means, that it is not exposed to public API. That means that you should not use it.

第二,回答您的问题:从实现中可以看到,它有一个公共方法,该方法设置了一个侦听器:

Secondly, to answer your question: as you can see from the implementation, it has one public method, which sets a listener:



    public void setOnFitSystemWindowsListener(OnFitSystemWindowsListener listener) {
        mListener = listener;
    }

当调用fitSystemWindows(Rect)时,将调用此侦听器:

And this listener would be called when fitSystemWindows(Rect) is called:



    @Override
    protected boolean fitSystemWindows(Rect insets) {
        if (mListener != null) {
            mListener.onFitSystemWindows(insets);
        }
        return super.fitSystemWindows(insets);
    }

这意味着,您可以通过以下方式检索Rect insets:

This means, that you can retrieve Rect insets following way:



    FitWindowsLinearLayout layout = new FitWindowsLinearLayout(context);

    layout.setOnFitSystemWindowsListener(new OnFitSystemWindowsListener() {
        boolean onFitSystemWindows(Rect insets) {
            // interact with `insets`
            return true;
        }
    })

要了解什么是插图,请参见说明.

To know what are insets see this explanation.

这篇关于LinearLayout和FitWindowsLinearLayout有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 18:38