Skip to content

Instantly share code, notes, and snippets.

@efturtle
Last active February 25, 2020 01:31
Show Gist options
  • Select an option

  • Save efturtle/47f30e12d23d74c955b04e4616e76958 to your computer and use it in GitHub Desktop.

Select an option

Save efturtle/47f30e12d23d74c955b04e4616e76958 to your computer and use it in GitHub Desktop.
layout of a basic calculator
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="96dp"
android:layout_height="296dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.984"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.997">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/button13"
android:layout_width="74dp"
android:layout_height="38dp"
android:layout_alignParentRight="true"
android:text="C"
android:onClick="cleartext"/>
</RelativeLayout>
<Button
android:id="@+id/buttonAdd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="suma"
android:text="@string/suma" />
<Button
android:id="@+id/buttonSub"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="resta"
android:text="@string/resta" />
<Button
android:id="@+id/buttonMul"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="multiplicacion"
android:text="@string/multiplicacion" />
<Button
android:id="@+id/buttonDiv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="division"
android:text="@string/division" />
<Button
android:id="@+id/buttonEnter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="enter"
android:text="@string/enter" />
</LinearLayout>
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/campo"
android:textSize="32sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.293" />
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="82dp"
android:layout_height="190dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/linearLayout3"
app:layout_constraintHorizontal_bias="0.551"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.961">
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="42dp"
android:onClick="button1"
android:text="@string/_1" />
<Button
android:id="@+id/button4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="button4"
android:text="@string/_4" />
<Button
android:id="@+id/button7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="button7"
android:text="@string/_7" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="82dp"
android:layout_height="210dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.337"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.997">
<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="42dp"
android:onClick="button2"
android:text="@string/_2" />
<Button
android:id="@+id/button5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="button5"
android:text="@string/_5" />
<Button
android:id="@+id/button8"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="button8"
android:text="@string/_8" />
<Button
android:id="@+id/button0"
android:layout_width="match_parent"
android:layout_height="63dp"
android:onClick="button0"
android:text="@string/_0" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout5"
android:layout_width="82dp"
android:layout_height="190dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/linearLayout2"
app:layout_constraintHorizontal_bias="0.326"
app:layout_constraintStart_toEndOf="@+id/linearLayout3"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.961">
<Button
android:id="@+id/button3"
android:layout_width="match_parent"
android:layout_height="42dp"
android:onClick="button3"
android:text="@string/_3" />
<Button
android:id="@+id/button6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="button6"
android:text="@string/_6" />
<Button
android:id="@+id/button9"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="button9"
android:text="@string/_9" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout4"
android:layout_width="281dp"
android:layout_height="79dp"
android:orientation="horizontal"
app:layout_constraintBottom_toTopOf="@+id/linearLayout3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.058"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.919">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="ySQRTx"
android:text="y √ x" />
<Button
android:id="@+id/button10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="potenciaE"
android:text="POT e" />
<Button
android:id="@+id/button11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="reciproca"
android:text="reciproca" />
<Button
android:id="@+id/button12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="raizCuadrada"
android:text="raiz 2" />
</LinearLayout>
<LinearLayout
android:layout_width="285dp"
android:layout_height="52dp"
android:orientation="horizontal"
app:layout_constraintBottom_toTopOf="@+id/linearLayout4"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.049"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0">
<!--This button is a number of the times of a root n-->
<Button
android:id="@+id/button14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="yPOTx"
android:onClick="yPotenciax"/>
<Button
android:id="@+id/button15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="LOG 10"
android:onClick="logaritmo10"/>
<!--Valor de 10 elevado a un numero ingresado-->
<Button
android:id="@+id/button16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="10 pot x"
android:onClick="Pot10"/>
<Button
android:id="@+id/button17"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/eX"
android:onClick="logaritmoNatural"/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment