2017-05-06 70 views

回答

0
<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.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:layout_editor_absoluteX="0dp" 
    tools:layout_editor_absoluteY="81dp"> 

    <EditText 
     android:id="@+id/result" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="8dp" 
     android:layout_marginStart="8dp" 
     android:layout_marginTop="8dp" 
     android:ems="10" 
     android:inputType="numberSigned" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintTop_toTopOf="parent" 
     tools:layout_constraintLeft_creator="1" 
     tools:layout_constraintTop_creator="1" /> 

    <Button 
     android:id="@+id/button0" 
     style="@style/Widget.AppCompat.Button.Colored" 
     android:layout_width="100dp" 
     android:layout_height="100dp" 
     android:text="0" 
     app:layout_constraintLeft_toRightOf="@+id/comma" 
     app:layout_constraintTop_toTopOf="@+id/comma" /> 

    <Button 
     android:id="@+id/button2" 
     style="@style/Widget.AppCompat.Button.Colored" 
     android:layout_width="100dp" 
     android:layout_height="100dp" 
     android:text="2" 
     app:layout_constraintLeft_toRightOf="@+id/button1" 
     app:layout_constraintTop_toTopOf="@+id/button1" /> 

    <Button 
     android:id="@+id/button3" 
     style="@style/Widget.AppCompat.Button.Colored" 
     android:layout_width="100dp" 
     android:layout_height="100dp" 
     android:text="3" 
     app:layout_constraintLeft_toRightOf="@+id/button2" 
     app:layout_constraintTop_toBottomOf="@+id/button5" /> 

    <Button 
     android:id="@+id/button4" 
     style="@style/Widget.AppCompat.Button.Colored" 
     android:layout_width="100dp" 
     android:layout_height="100dp" 
     android:text="4" 
     app:layout_constraintRight_toLeftOf="@+id/button8" 
     app:layout_constraintTop_toBottomOf="@+id/button7" /> 

    <Button 
     android:id="@+id/button5" 
     style="@style/Widget.AppCompat.Button.Colored" 
     android:layout_width="100dp" 
     android:layout_height="100dp" 
     android:text="5" 
     app:layout_constraintLeft_toRightOf="@+id/button4" 
     app:layout_constraintTop_toBottomOf="@+id/button7" /> 

    <Button 
     android:id="@+id/button6" 
     style="@style/Widget.AppCompat.Button.Colored" 
     android:layout_width="100dp" 
     android:layout_height="100dp" 
     android:text="6" 
     app:layout_constraintLeft_toRightOf="@+id/button5" 
     app:layout_constraintTop_toBottomOf="@+id/button8" /> 

    <Button 
     android:id="@+id/button7" 
     style="@style/Widget.AppCompat.Button.Colored" 
     android:layout_width="100dp" 
     android:layout_height="100dp" 
     android:layout_marginBottom="311dp" 
     android:layout_marginLeft="8dp" 
     android:text="7" 
     app:layout_constraintBottom_toBottomOf="parent" 
     app:layout_constraintLeft_toLeftOf="parent" 
     tools:layout_constraintTop_creator="1" /> 

    <Button 
     android:id="@+id/button8" 
     style="@style/Widget.AppCompat.Button.Colored" 
     android:layout_width="100dp" 
     android:layout_height="100dp" 
     android:text="8" 
     app:layout_constraintLeft_toRightOf="@+id/button7" 
     app:layout_constraintTop_toTopOf="@+id/button7" /> 

    <Button 
     android:id="@+id/button9" 
     style="@style/Widget.AppCompat.Button.Colored" 
     android:layout_width="100dp" 
     android:layout_height="100dp" 
     android:text="9" 
     app:layout_constraintLeft_toRightOf="@+id/button8" 
     app:layout_constraintTop_toTopOf="@+id/button8" /> 

    <Button 
     android:id="@+id/button1" 
     style="@style/Widget.AppCompat.Button.Colored" 
     android:layout_width="100dp" 
     android:layout_height="100dp" 
     android:text="1" 
     app:layout_constraintRight_toLeftOf="@+id/button5" 
     app:layout_constraintTop_toBottomOf="@+id/button4" /> 

    <Button 
     android:id="@+id/comma" 
     style="@style/Widget.AppCompat.Button.Colored" 
     android:layout_width="100dp" 
     android:layout_height="100dp" 
     android:text="," 
     app:layout_constraintRight_toRightOf="@+id/button1" 
     app:layout_constraintTop_toBottomOf="@+id/button1" /> 

    <Button 
     android:id="@+id/equal" 
     style="@style/Widget.AppCompat.Button.Colored" 
     android:layout_width="100dp" 
     android:layout_height="100dp" 
     android:text="=" 
     app:layout_constraintLeft_toRightOf="@+id/button0" 
     app:layout_constraintTop_toBottomOf="@+id/button2" /> 

    <Button 
     android:id="@+id/del" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_margin="4dp" 
     android:text="DEL" 
     app:layout_constraintBottom_toTopOf="@+id/divide" 
     app:layout_constraintLeft_toRightOf="@+id/equal" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintTop_toBottomOf="@+id/guideline" /> 

    <Button 
     android:id="@+id/divide" 
     style="@style/Widget.AppCompat.Button.Colored" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_margin="4dp" 
     android:text="÷" 
     app:layout_constraintBottom_toTopOf="@+id/multiply" 
     app:layout_constraintLeft_toRightOf="@+id/equal" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintTop_toBottomOf="@+id/del" /> 

    <Button 
     android:id="@+id/multiply" 
     style="@style/Widget.AppCompat.Button.Colored" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_margin="4dp" 
     android:text="x" 
     app:layout_constraintBottom_toTopOf="@+id/subtract" 
     app:layout_constraintLeft_toRightOf="@+id/equal" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintTop_toBottomOf="@+id/divide" /> 

    <Button 
     android:id="@+id/subtract" 
     style="@style/Widget.AppCompat.Button.Colored" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_margin="4dp" 
     android:text="-" 
     app:layout_constraintBottom_toTopOf="@+id/add" 
     app:layout_constraintLeft_toRightOf="@+id/equal" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintTop_toBottomOf="@+id/multiply" /> 

    <Button 
     android:id="@+id/add" 
     style="@style/Widget.AppCompat.Button.Colored" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_margin="4dp" 
     android:text="+" 
     app:layout_constraintBottom_toBottomOf="parent" 
     app:layout_constraintHorizontal_bias="0.0" 
     app:layout_constraintLeft_toRightOf="@+id/equal" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintTop_toBottomOf="@+id/subtract" /> 

    <android.support.constraint.Guideline 
     android:id="@+id/guideline" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     app:layout_constraintGuide_begin="191dp" /> 

</android.support.constraint.ConstraintLayout>