Question: Is it possible to have LinearLayout with layout\_height="match\_parent" and layout\_width that would attribute to half the height?

I would then put those layouts in larger HorizontalScrollView and let layouts keep desired aspect ratio.

Is this possible without creating my own layout that would handle it ?

Answer: 
You need a custom ViewGroup for this. Google has one called [ProportionalLayout](https://android.googlesource.com/platform/packages/apps/ContactsCommon/+/master/src/com/android/contacts/common/widget/ProportionalLayout.java) -- it's not part of the Android SDK, so you have to copy the source code into your app in order to use it in your XML layouts.

You also need to add this to `res/values/attrs.xml`:

```
<declare-styleable name="ProportionalLayout">
    <attr name="direction" format="string"/>
    <attr name="ratio" format="float"/>
</declare-styleable>

```
You can do that programmatically by getting the layout height and then set the width to half that size.

```
LinearLayout layout = (LinearLayout)findViewById(R.id.numberPadLayout);
int height = layout.getHeight();
LayoutParams params = layout.getLayoutParams();
params.height = height;
params.width = height/2;

```