我有GridView(键盘)禁用启用按钮......!

时间:2016-10-07 13:02:18

标签: android button gridview android-edittext

嘿我在GridView中有键盘按钮看到图片所以当我按下数字时我想要按钮禁用按钮(可以(假)但是当我像1234一样写入时这4个按钮被禁用,所以如果按下退格键(删除号码) 4然后从编辑文本3)这2个数字将启用看看我的xml和代码和图片以及PLZ帮助..!

已解决,此代码是解决方案

[GridView buttons with edit text[1]

    editText = (EditText) findViewById(R.id.editText);
    b1 = (Button) findViewById(R.id.n1);
    b2 = (Button) findViewById(R.id.n2);
    b3 = (Button) findViewById(R.id.n3);
    b4 = (Button) findViewById(R.id.n4);
    b5 = (Button) findViewById(R.id.n5);
    b6 = (Button) findViewById(R.id.n6);
    b7 = (Button) findViewById(R.id.n7);
    b8 = (Button) findViewById(R.id.n8);
    b9 = (Button) findViewById(R.id.n9);
    b0 = (Button) findViewById(R.id.n0);
    del = (Button) findViewById(R.id.enter);
    clr = (Button) findViewById(R.id.Clear);
    buttonEffect(b0);
    buttonEffect(b1);
    buttonEffect(b2);
    buttonEffect(b3);
    buttonEffect(b4);
    buttonEffect(b5);
    buttonEffect(b6);
    buttonEffect(b7);
    buttonEffect(b8);
    buttonEffect(b9);



    b1.setVisibility(View.INVISIBLE);
    b2.setVisibility(View.INVISIBLE);
    b3.setVisibility(View.INVISIBLE);
    b4.setVisibility(View.INVISIBLE);
    b5.setVisibility(View.INVISIBLE);
    b6.setVisibility(View.INVISIBLE);
    b7.setVisibility(View.INVISIBLE);
    b8.setVisibility(View.INVISIBLE);
    b9.setVisibility(View.INVISIBLE);
    b0.setVisibility(View.INVISIBLE);
    del.setVisibility(View.INVISIBLE);
    clr.setVisibility(View.INVISIBLE);


    editText.setShowSoftInputOnFocus(false);

    editText.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            b1.setVisibility(View.VISIBLE);
            b2.setVisibility(View.VISIBLE);
            b3.setVisibility(View.VISIBLE);
            b4.setVisibility(View.VISIBLE);
            b5.setVisibility(View.VISIBLE);
            b6.setVisibility(View.VISIBLE);
            b7.setVisibility(View.VISIBLE);
            b8.setVisibility(View.VISIBLE);
            b9.setVisibility(View.VISIBLE);
            b0.setVisibility(View.VISIBLE);
            del.setVisibility(View.VISIBLE);
            clr.setVisibility(View.VISIBLE);
            return false;
        }
    });





    editText.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            textContainer = s.toString();
            prevLength = s.length();
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            length = s.length();
            if (!textContainer.isEmpty()) {
                if (s.length() > 1) {
                    if (prevLength < length) {
                        if (!textContainer.contains(s.toString().subSequence(length - 1, length))) {
                            length = s.length();
                        } else {
                            editText.getText().delete(length - 1, length);
                        }
                    }
                }
            } else {
                textContainer = s.toString();
            }


        }
    });




    b0.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            editText.setText(editText.getText().insert(editText.getText().length(), "0"));
            b0.setBackgroundDrawable(getResources().getDrawable(R.drawable.redww));

            b0.setEnabled(false);

        }
    });


    b1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            editText.setText(editText.getText().insert(editText.getText().length(), "1"));
            b1.setBackgroundDrawable(getResources().getDrawable(R.drawable.redww));

            b1.setEnabled(false);


        }
    });

    b2.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            editText.setText(editText.getText().insert(editText.getText().length(), "2"));
            b2.setBackgroundDrawable(getResources().getDrawable(R.drawable.redww));

            b2.setEnabled(false);

        }
    });


    b3.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            editText.setText(editText.getText().insert(editText.getText().length(), "3"));
            b3.setBackgroundDrawable(getResources().getDrawable(R.drawable.redww));

            b3.setEnabled(false);

        }
    });


    b4.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            editText.setText(editText.getText().insert(editText.getText().length(), "4"));
            b4.setBackgroundDrawable(getResources().getDrawable(R.drawable.redww));

            b4.setEnabled(false);

        }
    });


    b5.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            editText.setText(editText.getText().insert(editText.getText().length(), "5"));
            b5.setBackgroundDrawable(getResources().getDrawable(R.drawable.redww));

            b5.setEnabled(false);

        }
    });


    b6.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            editText.setText(editText.getText().insert(editText.getText().length(), "6"));
            b6.setBackgroundDrawable(getResources().getDrawable(R.drawable.redww));

            b6.setEnabled(false);

        }
    });


    b7.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            editText.setText(editText.getText().insert(editText.getText().length(), "7"));
            b7.setBackgroundDrawable(getResources().getDrawable(R.drawable.redww));

            b7.setEnabled(false);

        }
    });


    b8.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            editText.setText(editText.getText().insert(editText.getText().length(), "8"));
            b8.setBackgroundDrawable(getResources().getDrawable(R.drawable.redww));

            b8.setEnabled(false);

        }
    });


    b9.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            editText.setText(editText.getText().insert(editText.getText().length(), "9"));

            b9.setBackgroundDrawable(getResources().getDrawable(R.drawable.redww));
            b9.setEnabled(false);

        }
    });


    del.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            int length = editText.getText().length();
            if (length > 0) {
                editText.getText().delete(length - 1, length);
            }

            if (editText.getText().toString().contains("0")) {
                b0.setBackgroundDrawable(getResources().getDrawable(R.drawable.redww));
            }
            else{
                b0.setBackgroundDrawable(getResources().getDrawable(R.drawable.greenww));
                b0.setEnabled(true);

            }
            if (editText.getText().toString().contains("1")) {
                b1.setBackgroundDrawable(getResources().getDrawable(R.drawable.redww));
            }
            else{
                b1.setBackgroundDrawable(getResources().getDrawable(R.drawable.greenww));
                b1.setEnabled(true);

            }
            if (editText.getText().toString().contains("2")) {
                b2.setBackgroundDrawable(getResources().getDrawable(R.drawable.redww));
            }
            else{
                b2.setBackgroundDrawable(getResources().getDrawable(R.drawable.greenww));
                b2.setEnabled(true);

            }
            if (editText.getText().toString().contains("3")) {
                b3.setBackgroundDrawable(getResources().getDrawable(R.drawable.redww));
            }
            else{
                b3.setBackgroundDrawable(getResources().getDrawable(R.drawable.greenww));
                b3.setEnabled(true);

            }
            if (editText.getText().toString().contains("4")) {
                b4.setBackgroundDrawable(getResources().getDrawable(R.drawable.redww));
            }
            else{
                b4.setBackgroundDrawable(getResources().getDrawable(R.drawable.greenww));
                b4  .setEnabled(true);

            }
            if (editText.getText().toString().contains("5")) {
                b5.setBackgroundDrawable(getResources().getDrawable(R.drawable.redww));
            }
            else{
                b5.setBackgroundDrawable(getResources().getDrawable(R.drawable.greenww));
                b5.setEnabled(true);

            }
            if (editText.getText().toString().contains("6")) {
                b6.setBackgroundDrawable(getResources().getDrawable(R.drawable.redww));
            }
            else{
                b6.setBackgroundDrawable(getResources().getDrawable(R.drawable.greenww));
                b6.setEnabled(true);

            }
            if (editText.getText().toString().contains("7")) {
                b7.setBackgroundDrawable(getResources().getDrawable(R.drawable.redww));
            }
            else{
                b7.setBackgroundDrawable(getResources().getDrawable(R.drawable.greenww));
                b7.setEnabled(true);

            }
            if (editText.getText().toString().contains("8")) {
                b8.setBackgroundDrawable(getResources().getDrawable(R.drawable.redww));
            }
            else{
                b8.setBackgroundDrawable(getResources().getDrawable(R.drawable.greenww));
                b8.setEnabled(true);

            }
            if (editText.getText().toString().contains("9")) {
                b9.setBackgroundDrawable(getResources().getDrawable(R.drawable.redww));
            }
            else{

                b9.setBackgroundDrawable(getResources().getDrawable(R.drawable.greenww));
                b9.setEnabled(true);
            }
        }
    });


    clr.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            editText.setText("");
        }
    });


}

public static void buttonEffect(View button){
    button.setOnTouchListener(new View.OnTouchListener() {

        public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
                case MotionEvent.ACTION_DOWN: {
                    v.getBackground().setColorFilter(0xe0ffffff, PorterDuff.Mode.SRC_ATOP);
                    v.invalidate();
                    break;
                }

                case MotionEvent.ACTION_UP: {
                    v.getBackground().clearColorFilter();
                    v.invalidate();
                    break;
                }
            }

            return false;
        }
    });
}





@Override
public void onBackPressed() {
    b1.setVisibility(View.INVISIBLE);
    b2.setVisibility(View.INVISIBLE);
    b3.setVisibility(View.INVISIBLE);
    b4.setVisibility(View.INVISIBLE);
    b5.setVisibility(View.INVISIBLE);
    b6.setVisibility(View.INVISIBLE);
    b7.setVisibility(View.INVISIBLE);
    b8.setVisibility(View.INVISIBLE);
    b9.setVisibility(View.INVISIBLE);
    b0.setVisibility(View.INVISIBLE);
    del.setVisibility(View.INVISIBLE);
    clr.setVisibility(View.INVISIBLE);

}

@Override
public boolean onTouchEvent(MotionEvent event) {
    b1.setVisibility(View.INVISIBLE);
    b2.setVisibility(View.INVISIBLE);
    b3.setVisibility(View.INVISIBLE);
    b4.setVisibility(View.INVISIBLE);
    b5.setVisibility(View.INVISIBLE);
    b6.setVisibility(View.INVISIBLE);
    b7.setVisibility(View.INVISIBLE);
    b8.setVisibility(View.INVISIBLE);
    b9.setVisibility(View.INVISIBLE);
    b0.setVisibility(View.INVISIBLE);
    del.setVisibility(View.INVISIBLE);
    clr.setVisibility(View.INVISIBLE);
    return    super.onTouchEvent(event);

}

}

的xml:

        <?xml version="1.0" encoding="utf-8"?>
   <RelativeLayout 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: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.example.mike.keyboard2.MainActivity">



<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="400dp"
    android:gravity="bottom"
    android:orientation="vertical"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:focusable="true"
    android:focusableInTouchMode="true">


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="3dp"
        android:orientation="horizontal">

        <Button
            android:id="@+id/n1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@drawable/colors"
            android:minHeight="80dp"
            android:text="1"
            android:textColor="#333"
            android:textSize="25sp" />

        <Button
            android:id="@+id/n2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="2dp"
            android:layout_weight="1"
            android:background="@drawable/colors"
            android:minHeight="80dp"
            android:text="2"
            android:textColor="#333"
            android:textSize="25sp" />

        <Button
            android:id="@+id/n3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="2dp"
            android:layout_marginRight="2dp"
            android:layout_weight="1"
            android:background="@drawable/colors"
            android:minHeight="80dp"
            android:text="3"
            android:textColor="#333"
            android:textSize="25sp" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="#112"
            android:minHeight="80dp"
            android:text="clear"
            android:textColor="@color/colorPrimaryDark"
            android:textSize="25sp"
            android:textStyle="bold"
            android:id="@+id/Clear" />
    </LinearLayout>


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="2dp"
        android:orientation="horizontal">

        <Button
            android:id="@+id/n4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@drawable/colors"
            android:minHeight="80dp"
            android:text="4"
            android:textColor="#333"
            android:textSize="25sp" />

        <Button
            android:id="@+id/n5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="2dp"
            android:layout_weight="1"
            android:background="@drawable/colors"
            android:minHeight="80dp"
            android:text="5"
            android:textColor="#333"
            android:textSize="25sp" />

        <Button
            android:id="@+id/n6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="2dp"
            android:layout_marginRight="2dp"
            android:layout_weight="1"
            android:background="@drawable/colors"
            android:minHeight="80dp"
            android:text="6"
            android:textColor="#333"
            android:textSize="25sp" />

        <Button
            android:id="@+id/enter"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="#ccc"
            android:minHeight="80dp"
            android:text="enter"
            android:textColor="@color/colorPrimaryDark"
            android:textSize="25sp"
            android:textStyle="bold" />
    </LinearLayout>


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="2dp"
        android:orientation="horizontal">

        <Button
            android:id="@+id/n7"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@drawable/colors"
            android:minHeight="80dp"
            android:text="7"
            android:textColor="#333"
            android:textSize="25sp" />

        <Button
            android:id="@+id/n8"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="2dp"
            android:layout_weight="1"
            android:background="@drawable/colors"
            android:minHeight="80dp"
            android:text="8"
            android:textColor="#333"
            android:textSize="25sp" />

        <Button
            android:id="@+id/n9"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="2dp"
            android:layout_marginRight="2dp"
            android:layout_weight="1"
            android:background="@drawable/colors"
            android:minHeight="80dp"
            android:text="9"
            android:textColor="#333"
            android:textSize="25sp" />

        <Button
            android:id="@+id/n0"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="2dp"
            android:layout_weight="1"
            android:background="@drawable/colors"
            android:minHeight="80dp"
            android:text="0"
            android:textColor="#333"
            android:textSize="25sp" />

    </LinearLayout>

</LinearLayout>

<EditText
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/editText"
    android:inputType="number"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true" />

   </RelativeLayout>

1 个答案:

答案 0 :(得分:0)

我的班级:

public class MainActivity extends AppCompatActivity implements View.OnClickListener{
TextView tvKeyBoard;

Button btn[] = new Button[10];
ArrayList<Integer> clickCount = new ArrayList<>();

String fullNamber = "";

Button del, clear;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    tvKeyBoard = (TextView) findViewById(R.id.tv_keyboard);
    del = (Button) findViewById(R.id.enter);
    clear = (Button) findViewById(R.id.Clear);
    btn[0] = (Button) findViewById(R.id.n1);
    btn[1] = (Button) findViewById(R.id.n2);
    btn[2] = (Button) findViewById(R.id.n3);
    btn[3] = (Button) findViewById(R.id.n4);
    btn[4] = (Button) findViewById(R.id.n5);
    btn[5] = (Button) findViewById(R.id.n6);
    btn[6] = (Button) findViewById(R.id.n7);
    btn[7] = (Button) findViewById(R.id.n8);
    btn[8] = (Button) findViewById(R.id.n9);
    btn[9] = (Button) findViewById(R.id.n0);

    for (Button b : btn){
        b.setOnClickListener(this);
        b.setVisibility(View.INVISIBLE);
    }

    del.setVisibility(View.INVISIBLE);
    clear.setVisibility(View.INVISIBLE);


    del.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            if(clickCount.size() != 0) {
                btn[clickCount.get(clickCount.size()-1)].setEnabled(true);
                clickCount.remove(clickCount.size()-1);
            }
            if(!fullNamber.isEmpty()) {
                fullNamber = fullNamber.substring(0, fullNamber.length() - 1);
                tvKeyBoard.setText(fullNamber);
            }
        }
    });

    clear.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            for (int i = 0; i < clickCount.size(); i++ ){
                btn[clickCount.get(i)].setEnabled(true);
            }
            clickCount.clear();
        }
    });

    tvKeyBoard.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            for (Button b : btn){
                b.setVisibility(View.VISIBLE);
            }
            del.setVisibility(View.VISIBLE);
            clear.setVisibility(View.VISIBLE);
            return false;
        }
    });




}

@Override
public void onClick(View v) {

    String number = "";

    switch (v.getId()){
        case R.id.n1:
            number  = "1";
            clickCount.add(0);
            btn[0].setEnabled(false);
            break;
        case R.id.n2:
            number  = "2";
            clickCount.add(1);
            btn[1].setEnabled(false);
            break;

        case R.id.n3:
            number  = "3";
            clickCount.add(2);
            btn[2].setEnabled(false);
            break;
        case R.id.n4:
            number  = "4";
            clickCount.add(3);
            btn[3].setEnabled(false);
            break;
        case R.id.n5:
            number  = "5";
            clickCount.add(4);
            btn[4].setEnabled(false);
            break;

        case R.id.n6:
            number  = "6";
            clickCount.add(5);
            btn[5].setEnabled(false);
            break;

        case R.id.n7:
            number  = "7";
            clickCount.add(6);
            btn[6].setEnabled(false);
            break;
        case R.id.n8:
            number  = "8";
            clickCount.add(7);
            btn[7].setEnabled(false);
            break;

        case R.id.n9:
            number  = "9";
            clickCount.add(8);
            btn[8].setEnabled(false);
            break;

        case R.id.n0:
            number  = "0";
            clickCount.add(9);
            btn[9].setEnabled(false);
            break;


    }
    if(fullNamber.length() != 4) {
        fullNamber = fullNamber.concat(number);
        tvKeyBoard.setText(fullNamber);
    }


}

@Override
public void onBackPressed() {


    if(del.isEnabled()){
        for (Button b : btn){
            b.setVisibility(View.INVISIBLE);

        }
        del.setVisibility(View.INVISIBLE);
        clear.setVisibility(View.INVISIBLE);
    }else
        super.onBackPressed();

}

}

xml文件:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">



<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="400dp"
    android:gravity="bottom"
    android:orientation="vertical"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:focusable="true"
    android:focusableInTouchMode="true">


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="3dp"
        android:orientation="horizontal">

        <Button
            android:id="@+id/n1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:minHeight="80dp"
            android:text="1"
            android:textColor="#333"
            android:textSize="25sp" />

        <Button
            android:id="@+id/n2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="2dp"
            android:layout_weight="1"
            android:minHeight="80dp"
            android:text="2"
            android:textColor="#333"
            android:textSize="25sp" />

        <Button
            android:id="@+id/n3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="2dp"
            android:layout_marginRight="2dp"
            android:layout_weight="1"
            android:minHeight="80dp"
            android:text="3"
            android:textColor="#333"
            android:textSize="25sp" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="#112"
            android:minHeight="80dp"
            android:text="clear"
            android:textColor="@color/colorPrimaryDark"
            android:textSize="25sp"
            android:textStyle="bold"
            android:id="@+id/Clear" />
    </LinearLayout>


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="2dp"
        android:orientation="horizontal">

        <Button
            android:id="@+id/n4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:minHeight="80dp"
            android:text="4"
            android:textColor="#333"
            android:textSize="25sp" />

        <Button
            android:id="@+id/n5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="2dp"
            android:layout_weight="1"
            android:minHeight="80dp"
            android:text="5"
            android:textColor="#333"
            android:textSize="25sp" />

        <Button
            android:id="@+id/n6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="2dp"
            android:layout_marginRight="2dp"
            android:layout_weight="1"
            android:minHeight="80dp"
            android:text="6"
            android:textColor="#333"
            android:textSize="25sp" />

        <Button
            android:id="@+id/enter"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="#ccc"
            android:minHeight="80dp"
            android:text="enter"
            android:textColor="@color/colorPrimaryDark"
            android:textSize="25sp"
            android:textStyle="bold" />
    </LinearLayout>


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="2dp"
        android:orientation="horizontal">

        <Button
            android:id="@+id/n7"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:minHeight="80dp"
            android:text="7"
            android:textColor="#333"
            android:textSize="25sp" />

        <Button
            android:id="@+id/n8"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="2dp"
            android:layout_weight="1"
            android:minHeight="80dp"
            android:text="8"
            android:textColor="#333"
            android:textSize="25sp" />

        <Button
            android:id="@+id/n9"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="2dp"
            android:layout_marginRight="2dp"
            android:layout_weight="1"
            android:minHeight="80dp"
            android:text="9"
            android:textColor="#333"
            android:textSize="25sp" />

        <Button
            android:id="@+id/n0"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="2dp"
            android:layout_weight="1"
            android:minHeight="80dp"
            android:text="0"
            android:textColor="#333"
            android:textSize="25sp" />

    </LinearLayout>

</LinearLayout>

<TextView
    android:layout_width="fill_parent"
    android:layout_height="40dp"
    android:id="@+id/tv_keyboard"
    android:gravity="center_vertical"
    android:textSize="28sp"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:background="@drawable/tvstroke"/>

</RelativeLayout>