Question: 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**.

Answer: 
The [source code](https://github.com/android/platform_frameworks_base/blob/master/core/java/com/android/internal/widget/ButtonBarLayout.java) 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. */

```

[Source Code Here](https://github.com/android/platform_frameworks_base/blob/master/core/java/com/android/internal/widget/ButtonBarLayout.java)
<https://android.googlesource.com/platform/frameworks/base/+/master/core/java/com/android/internal/widget/ButtonBarLayout.java>

Looking into the code, I think it's a LinearLayout for buttons (duh). You can probably look at it like the Dialog buttons divided by a vertical spacer: | . AllowStacking will change the orientation to vertical and the gravity to the right instead of bottom. I should try it out to give a better answer