android - 使用GridLayout设计自定义键盘

时间:2015-08-24 23:20:39

标签: android keyboard

我想设计自定义键盘,但我发现视图有问题

enter image description here

另一种观点

with

我的xml文件

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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/voucherrelative"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/vouchertxt"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:layout_marginTop="20dp"
        android:gravity="center"
        android:text="Enter Voucher Code"
        android:textSize="25sp" />

    <LinearLayout
        android:id="@+id/codeLinear"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/vouchertxt"
        android:layout_marginBottom="20dp"
        android:layout_marginTop="20dp"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:orientation="horizontal"
        android:weightSum="3">

        <EditText
            android:id="@+id/code1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginRight="2dp"
            android:layout_weight="1"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:gravity="center"
            android:imeOptions="actionDone"
            android:inputType="number"
            android:maxLength="3"
            android:nextFocusUp="@+id/code2"
            android:singleLine="true"
            android:textCursorDrawable="@drawable/black_cursor"
            android:textSize="25dp" />


        <EditText
            android:id="@+id/code2"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginRight="2dp"
            android:layout_weight="1"
            android:gravity="center"
            android:imeOptions="actionNext"
            android:inputType="number"
            android:maxLength="3"
            android:nextFocusDown="@+id/code1"
            android:nextFocusUp="@+id/code3"
            android:textCursorDrawable="@drawable/black_cursor"
            android:textSize="25dp" />

        <EditText
            android:id="@+id/code3"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center"
            android:inputType="number"
            android:maxLength="3"
            android:nextFocusDown="@+id/code2"
            android:textCursorDrawable="@drawable/black_cursor"
            android:textSize="25dp" />

    </LinearLayout>


    <LinearLayout
        android:id="@+id/check_linear"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/codeLinear"
        android:orientation="horizontal">

        <Button
            android:id="@+id/scanqr"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginBottom="5dp"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:layout_weight="2"
            android:background="@drawable/roundedwhite"
            android:text="Scan "
            android:textColor="#191919" />

        <Button
            android:id="@+id/buttoncheck"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:layout_weight="2"
            android:background="@drawable/roundedbutton"
            android:text="Check"
            android:textColor="#ffffff"

            />
    </LinearLayout>


    <android.support.v7.widget.GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/check_linear"
        app:alignmentMode="alignBounds"
        app:columnCount="4"
        app:columnOrderPreserved="false"
        app:orientation="horizontal"
        app:rowCount="5"
        app:useDefaultMargins="false">

        <Button
            android:id="@+id/button7"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"

            android:layout_marginBottom="5dp"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:layout_marginTop="5dp"
            android:background="@drawable/roundedbutton"
            android:text="7"
            android:textColor="#ffffff"

            app:layout_row="1" />

        <Button
            android:id="@+id/button8"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="5dp"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:layout_marginTop="5dp"
            android:background="@drawable/roundedbutton"
            android:text="8"
            android:textColor="#ffffff"
            app:layout_row="1" />

        <Button
            android:id="@+id/button9"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="5dp"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:layout_marginTop="5dp"
            android:background="@drawable/roundedbutton"
            android:text="9"
            android:textColor="#ffffff"
            app:layout_column="2"
            app:layout_row="1" />


        <Button
            android:id="@+id/buttonDel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="5dp"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:layout_marginTop="5dp"
            android:background="@drawable/roundedwhite"
            android:text="Del"
            android:textColor="#191919"


            app:layout_column="3"
            app:layout_row="1"
            app:layout_rowSpan="2"
            app:layout_gravity="fill_vertical"

            />


        <Button
            android:id="@+id/button4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="5dp"

            android:background="@drawable/roundedbutton"
            android:text="4"
            android:textColor="#ffffff"
            app:layout_column="0"

            app:layout_row="2" />

        <Button
            android:id="@+id/button5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/roundedbutton"

            android:text="5"
            android:textColor="#ffffff"
            app:layout_column="1"
            app:layout_row="2" />

        <Button
            android:id="@+id/button6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"

            android:background="@drawable/roundedbutton"
            android:text="6"
            android:textColor="#ffffff"
            app:layout_column="2"

            app:layout_row="2" />


        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="5dp"
            android:layout_weight="1"
            android:background="@drawable/roundedbutton"
            android:text="1"
            android:textColor="#ffffff"

            app:layout_column="0"
            app:layout_row="3" />

        <Button
            android:id="@+id/button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/roundedbutton"
            android:text="2"
            android:textColor="#ffffff"
            app:layout_column="1"
            app:layout_row="3" />


        <Button
            android:id="@+id/button3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/roundedbutton"
            android:text="3"
            android:textColor="#ffffff"
            app:layout_column="2"
            app:layout_row="3" />

        <Button
            android:id="@+id/buttonclear"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/roundedwhite"
            android:text="Clear"
            android:textColor="#191919"
            app:layout_gravity="fill_vertical"
            app:layout_row="3"
            app:layout_rowSpan="2"/>

        <Button
            android:id="@+id/button0"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="2dp"
            android:layout_weight="2"
            android:background="@drawable/roundedbutton"
            android:text="0"
            android:textColor="#ffffff"
            app:layout_column="0"
            app:layout_columnSpan="2"

            app:layout_columnWeight="2"
            app:layout_gravity="fill_horizontal"
            app:layout_row="4" />

        <Button
            android:id="@+id/btn55"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/roundedbutton"
            android:text="."
            android:textColor="#ffffff"
            app:layout_column="2"
            app:layout_row="4" />


    </android.support.v7.widget.GridLayout>


</RelativeLayout>

任何有关如何使这款键盘看起来更好的建议

0 个答案:

没有答案
相关问题