---
title: "How to set layout  height and weight in percentage android?"  
description: "How to set layout  height and weight in percentage android?"  
author: "Anonymous User"  
published: 2015-02-20  
updated: 2015-02-20  
canonical: https://www.mindstick.com/forum/12970/how-to-set-layout-height-and-weight-in-percentage-android  
category: "android"  
tags: ["android layout"]  
reading_time: 1 minute  

---

# How to set layout  height and weight in percentage android?

How to set [layout](https://www.mindstick.com/articles/12853/android-layout-and-its-type) height and [weight](https://www.mindstick.com/articles/12951/the-importance-of-breakfast-in-weight-reduction) in percentage [android](https://www.mindstick.com/articles/13046/10-reasons-why-i-prefer-android-vs-iphone-ios)

## Replies

### Reply by Anonymous User

You need to add weight in your controls xml file. Here I am giving a sample, which help you to set height and weight in percentage.

```
   <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:orientation="vertical"   tools:context=".MainActivity" >   <!--weight=".5" means 50 percantage -->   <LinearLayout       android:layout_width="fill_parent"       android:layout_height="0dp"       android:layout_weight=".5"       android:orientation="horizontal" >       <TextView           android:layout_width="0dp"           android:layout_height="wrap_content"           android:layout_weight=".5"           android:gravity="center"           android:text="Sample1" />        <TextView            android:layout_width="0dp"            android:layout_height="wrap_content"            android:layout_weight=".5"            android:gravity="center"            android:text="Sample2" />    </LinearLayout>    <LinearLayout        android:layout_width="fill_parent"        android:layout_height="0dp"        android:layout_weight=".5"        android:orientation="horizontal" >        <Button            android:layout_width="0dp"            android:layout_height="wrap_content"            android:layout_weight=".5"            android:gravity="center"            android:text="Sample1" />        <Button            android:layout_width="0dp"            android:layout_height="wrap_content"            android:layout_weight=".5"            android:gravity="center"            android:text="Sample2" />    </LinearLayout></LinearLayout>
```

![How to set layout  height and weight in percentage android?](https://www.mindstick.com/mindstickforums/21d3188c-13b9-4017-b0ec-ed14373d4a6c/images/a7524b8c-ca72-45f8-aaaa-8349c5631d1d.png) ![How to set layout  height and weight in percentage android?](https://www.mindstick.com/mindstickforums/21d3188c-13b9-4017-b0ec-ed14373d4a6c/images/8cd4a3d8-09f0-4adc-9471-3c93bfff85f6.png)\


---

Original Source: https://www.mindstick.com/forum/12970/how-to-set-layout-height-and-weight-in-percentage-android

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
