如何在android中制作ios拨号盘界面 [英] how to make a ios dial pad interface in android

查看:97
本文介绍了如何在android中制作ios拨号盘界面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想制作一个拨号盘,就像Android中带圆圈按钮的IOS 7一样.任何人都可以帮助我制作一个android支持的具有不同手机屏幕的圆形按钮拨号盘界面.

i want to make a dial pad just like IOS 7 in android with circle button. Any one can help me to make a circle button dial pad interface with different mobile screen supported in android.

推荐答案

如果我想为该拨号盘编写代码,将花费很多时间.因此,我写了一些可能对您有帮助的步骤,以及可以向您展示方式的代码的某些部分:

It will take a lot of time if I want to write the code for that dial pad. So I write some steps that might help you plus some parts of a code that can show you the way:

  1. 制作2个可绘制的形状文件. 2个椭圆形的按钮. (默认为1,其他为按下状态)

  1. Make 2 drawable shape files. 2 oval shapes for buttons. (1 for default the other for pressed state)

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
   android:shape="oval">

    <stroke android:width="1dp" android:color="COLOR" />

</shape>

  • 为按钮创建一个选择器可绘制文件,当用户按下按钮时,它将更改背景.

  • Make a selector drawable file for your button that will change the background when user pushes the button.

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
    
           <item android:state_pressed="true"
               android:drawable="@drawable/drawable2" />
    
           <item android:drawable="@drawable/drawable1" />
    
    </selector>
    

  • 为键盘设置样式.将选择器设置为按钮的背景.

  • Make a style for your keypad. Set your selector as the background for your buttons.

    <style name="keypad">
    
        <item name="android:layout_margin">4dp</item>
        <item name="android:layout_width">0dp</item>
        <item name="android:layout_height">match_parent</item>
        <item name="android:layout_weight">1</item>
        <item name="android:textSize">@dimen/text_size_large</item>
        <item name="android:textStyle">bold</item>
        <item name="android:textColor">@color/black</item>
        <item name="android:background">@drawable/btn_blue</item>
    
    </style>
    

  • dimens文件夹中为不同的屏幕尺寸提供不同的尺寸,然后将其用作按钮的尺寸.

  • Provide different sizes for different screen sizes in dimens folder then use it as the size of your buttons.

    1. 制作一个Linear-layout并在该布局内添加4或5个其他Linear-layouts.

    1. Make a Linear-layout and add 4 or 5 other Linear-layouts inside that layout.

    <LinearLayout
        style="@style/linearLayouts.vertical"
        android:id="@+id/layout_keypad"
        android:layout_marginBottom="4dp">
    
        <LinearLayout
            style="@style/linearLayouts.horizontal"
            android:id="@+id/bar_1to3">
    
            <Button
                style="@style/keypad"
                android:text="@string/btn_1"
                android:id="@+id/btn_1"
                android:layout_weight="1"/>
    
            <Button
                style="@style/keypad"
                android:text="@string/btn_2"
                android:id="@+id/btn_2"/>
    
            <Button
                style="@style/keypad"
                android:text="@string/btn_3"
                android:id="@+id/btn_3"/>
    
        </LinearLayout>
    
        <LinearLayout
            style="@style/linearLayouts.horizontal"
            android:id="@+id/bar_4to6">
    
            <Button
                style="@style/keypad"
                android:text="@string/btn_4"
                android:id="@+id/btn_4"/>
    
            <Button
                style="@style/keypad"
                android:text="@string/btn_5"
                android:id="@+id/btn_5"/>
    
            <Button
                style="@style/keypad"
                android:text="@string/btn_6"
                android:id="@+id/btn_6"/>
    
        </LinearLayout>
    
        <LinearLayout
            style="@style/linearLayouts.horizontal"
            android:id="@+id/bar_7to9">
    
            <Button
                style="@style/keypad"
                android:text="@string/btn_7"
                android:id="@+id/btn_7"/>
    
            <Button
                style="@style/keypad"
                android:text="@string/btn_8"
                android:id="@+id/btn_8"/>
    
            <Button
                style="@style/keypad"
                android:text="@string/btn_9"
                android:id="@+id/btn_9"/>
    
        </LinearLayout>
    
        <LinearLayout
            style="@style/linearLayouts.horizontal"
            android:id="@+id/bar_0toH">
    
    
            <Button
                style="@style/keypad"
                android:text="*"
                android:id="@+id/btn_s"/>
    
            <Button
                style="@style/keypad"
                android:text="@string/btn_0"
                android:id="@+id/btn_0"/>
    
            <Button
                style="@style/keypad"
                android:text="#"
                android:id="@+id/btn_h"/>
    
        </LinearLayout>
    </LinearLayout>
    

  • 这是输出:

    我没有提供按钮尺寸的变暗.因此,这些按钮不是圆形的.我希望这能为您指明道路.不要忘记投票;)

    I didn't provide dimens for my button size. So these buttons are not circle. I hope this shows you the way. Don't forget to vote up ;)

    这篇关于如何在android中制作ios拨号盘界面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆