什么是ButtonBarLayout,我们应该如何使用它? [英] What is the ButtonBarLayout and how should we use it?
问题描述
开发时,我意外地发现了一个名为android.support.v7.widget.ButtonBarLayout
的新窗口小部件.我试图在Internet上进行搜索,但是即使在官方开发文档站点上也没有找到任何内容.
同时,当我在 Android Studio 中的任何地方搜索ButtonBarLayout
时,我发现了两个ButtonBarLayout
,一个是android.support.v7.widget.ButtonBarLayout
,另一个是com.android.internal.widget.ButtonBarLayout
.我试图阅读两者的源代码,发现除了软件包名称之外,它们是相同的.因此,我认为android.support.v7.widget.ButtonBarLayout
来自com.android.internal.widget.ButtonBarLayout
,可能是内部ButtonBarLayout
经过测试并发布的.同时,ButtonBarLayout
是从LinearLayout
继承的.
但是有一些问题:
- 从
ButtonBarLayout
的字面意义上我们可以得到什么?我们应该如何使用它? - 我注意到了
private boolean mAllowStacking
的变量.当它改变时,该布局的方向将改变.但是我真的不明白它的用途.
那么有人知道ButtonBarLayout
吗?
PS:我使用的是 2.0.0 Preview 4 的 Android Studio 和 2.0.0-alpha3 的 Gradle Plugin 23.1.1 的strong>和 Android支持库,以及 23.1 和 Build-工具( 23.0.2 ).
此处的源代码 >
When I developed, I found a new widget called android.support.v7.widget.ButtonBarLayout
unexpectedly. I tried to search it on the internet, but nothing was found, even on the official development documents site.
In the meantime, I found two ButtonBarLayout
when I search ButtonBarLayout
everywhere in Android Studio, one is android.support.v7.widget.ButtonBarLayout
and the other is com.android.internal.widget.ButtonBarLayout
. I tried to read source codes of both, I found that they are the same except package name. So I thought maybe android.support.v7.widget.ButtonBarLayout
came from com.android.internal.widget.ButtonBarLayout
after the internal ButtonBarLayout
was through tests and released. At the same time, ButtonBarLayout
is inherited from LinearLayout
.
But there are some question:
- What can we get from
ButtonBarLayout
literally and how should we use it? - I noticed the variable of
private boolean mAllowStacking
. When it changes, orientation of this layout would be changed. But I didn't really understand what it is used for.
So does somebody know ButtonBarLayout
well?
P.S.: I used Android Studio of 2.0.0 Preview 4 and Gradle Plugin of 2.0.0-alpha3 and Android Support Library of 23.1.1 and Platform-tools of 23.1 and Build-tools of 23.0.2.
The source code describes ButtonBarLayout
as follows:
/**
* An extension of LinearLayout that automatically switches to vertical
* orientation when it can't fit its child views horizontally.
*/
So, in essence, it is nothing but a smart LinearLayout
which manages auto-switching orientations based on available space on screen.
The same ButtonBarLayout.java
file describes mAllowStacking
in comments as follows:
/** Whether the current configuration allows stacking. */
这篇关于什么是ButtonBarLayout,我们应该如何使用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!