Egy egyszerű Számológép alkalmazást készítek, és nem tudom beilleszteni az elrendezést az egész képernyőre. Van egy TextView, egy EditText és egy gombom, és van egy kis szóköz, ami alatta marad. Azt szeretném, hogy az elrendezésem a teljes képernyőre kiterjedjen, mint az Android Számológépe.
Az XML kódfájlom a következő:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.varun.calculator.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lines="2"
android:maxLines="2"
android:textSize="35sp" />
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/textView"
android:enabled="false"
android:inputType="numberDecimal"
android:lines="2"
android:maxLines="2"
android:textSize="20sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/seven"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="7"
android:textSize="25sp" />
<Button
android:id="@+id/eight"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/seven"
android:text="8"
android:textSize="25sp" />
<Button
android:id="@+id/nine"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/eight"
android:text="9"
android:textSize="25sp" />
<Button
android:id="@+id/four"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/seven"
android:text="4"
android:textSize="25sp" />
<Button
android:id="@+id/five"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/eight"
android:layout_toRightOf="@id/four"
android:text="5"
android:textSize="25sp" />
<Button
android:id="@+id/six"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/nine"
android:layout_toRightOf="@id/five"
android:text="6"
android:textSize="25sp" />
<Button
android:id="@+id/one"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/four"
android:text="1"
android:textSize="25sp" />
<Button
android:id="@+id/two"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/five"
android:layout_toRightOf="@id/one"
android:text="2"
android:textSize="25sp" />
<Button
android:id="@+id/three"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/six"
android:layout_toRightOf="@id/two"
android:text="3"
android:textSize="25sp" />
<Button
android:id="@+id/dot"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/one"
android:text="."
android:textSize="25sp" />
<Button
android:id="@+id/zero"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/two"
android:layout_toRightOf="@id/dot"
android:text="0"
android:textSize="25sp" />
<Button
android:id="@+id/clear"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/three"
android:layout_toRightOf="@id/zero"
android:text="C"
android:textSize="25sp" />
<Button
android:id="@+id/div"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/nine"
android:text="/"
android:textSize="25sp" />
<Button
android:id="@+id/mul"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/div"
android:layout_toRightOf="@id/three"
android:text="*"
android:textSize="25sp" />
<Button
android:id="@+id/sub"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/mul"
android:layout_toRightOf="@id/clear"
android:text="-"
android:textSize="25sp" />
<Button
android:id="@+id/equal"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/dot"
android:text="="
android:textSize="25sp" />
<Button
android:id="@+id/add"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/sub"
android:layout_toRightOf="@id/three"
android:text="+"
android:textSize="25sp" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
Kérjük, ellenőrizze az itt linkelt képet: 1