xml - Android - Calculator support all screen sizes -


i'm beginner on android app developing , have problem cannot find solution. i'm working app on nexus 5 , works perfect, no empty spaces between layouts, when switch nexus 4, happens ( using colors separate layouts) :

https://scontent.fath3-1.fna.fbcdn.net/v/t34.0-12/20403684_1379424475444386_454511879_n.jpg?oh=440d7b9ab5670c8cad87133475ec0cb6&oe=5979cded


if switch pixel xl :

https://scontent.fath3-1.fna.fbcdn.net/v/t34.0-12/20403737_1379426118777555_859609190_n.jpg?oh=61ccd01da7a4470491fb4125da8db43c&oe=597996e4

can doesn't have empty spaces on right?(below there xml code posted in case need it).

<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:background="@android:color/black" android:orientation="vertical" android:weightsum="1">      <linearlayout         android:id="@+id/linearlayout1"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:background="#f00">          <button             android:id="@+id/button"             android:layout_width="match_parent"             android:layout_height="match_parent"             android:onclick="onclickdtb"             android:text="convert binary"             android:textalignment="center"             android:textallcaps="true"             android:textsize="14sp"             android:textstyle="bold|italic" />      </linearlayout>      <linearlayout         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:background="#0f0">          <textview             android:id="@+id/textview"             android:layout_width="match_parent"             android:layout_height="98dp"             android:layout_weight="0.01"             android:fontfamily="serif-monospace"             android:text="calculator"             android:textalignment="textend"             android:textcolor="@android:color/white"             android:textsize="35dp"             android:textstyle="bold" />     </linearlayout>   <linearlayout       android:layout_width="wrap_content"     android:layout_height="match_parent"     android:background="#f0f"     android:orientation="horizontal">      <linearlayout         android:layout_width="72.4dp"         android:layout_height="match_parent"         android:background="#ffa500"         android:orientation="vertical">      </linearlayout>      <linearlayout         android:layout_width="72.4dp"         android:layout_height="match_parent"         android:background="#000fff"         android:orientation="vertical">      </linearlayout>      <linearlayout         android:layout_width="72.4dp"         android:layout_height="match_parent"         android:background="#8b0000"         android:orientation="vertical">      </linearlayout>      <linearlayout         android:layout_width="72.4dp"         android:layout_height="match_parent"         android:background="#800080"         android:orientation="vertical">      </linearlayout>      <linearlayout         android:layout_width="72.4dp"         android:layout_height="match_parent"         android:background="#2e8b57"         android:orientation="vertical">      </linearlayout>   </linearlayout> 

you must use weight , weight sum this

<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:background="@android:color/black"     android:orientation="vertical"     android:weightsum="1">      <linearlayout         android:id="@+id/linearlayout1"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:background="#f00">          <button             android:id="@+id/button"             android:layout_width="match_parent"             android:layout_height="match_parent"             android:onclick="onclickdtb"             android:text="convert binary"             android:textalignment="center"             android:textallcaps="true"             android:textsize="14sp"             android:textstyle="bold|italic" />      </linearlayout>      <linearlayout         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:background="#0f0">          <textview             android:id="@+id/textview"             android:layout_width="match_parent"             android:layout_height="98dp"             android:layout_weight="0.01"             android:fontfamily="serif-monospace"             android:text="calculator"             android:textalignment="textend"             android:textcolor="@android:color/white"             android:textsize="35dp"             android:textstyle="bold" />     </linearlayout>       <linearlayout           android:layout_width="match_parent"         android:layout_height="match_parent"         android:background="#f0f"         android:weightsum="100"         android:orientation="horizontal">          <linearlayout             android:layout_width="0dp"             android:layout_weight="20"             android:layout_height="match_parent"             android:background="#ffa500"             android:orientation="vertical">          </linearlayout>          <linearlayout             android:layout_width="0dp"             android:layout_weight="20"             android:layout_height="match_parent"             android:background="#000fff"             android:orientation="vertical">          </linearlayout>          <linearlayout             android:layout_width="0dp"             android:layout_height="match_parent"             android:layout_weight="20"             android:background="#8b0000"             android:orientation="vertical">          </linearlayout>          <linearlayout             android:layout_width="0dp"             android:layout_weight="20"             android:layout_height="match_parent"             android:background="#800080"             android:orientation="vertical">          </linearlayout>          <linearlayout             android:layout_width="0dp"             android:layout_height="match_parent"             android:layout_weight="20"             android:background="#2e8b57"             android:orientation="vertical">          </linearlayout>       </linearlayout>     </linearlayout> 

Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -