本文来自网易云社区

作者:孙有军

首先来看看拨号界面的配置代码:

<LinearLayout 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:background="@color/transparent"
              android:orientation="horizontal"
              tools:context="im.yixin.home.dial.DialFragment">     <FrameLayout
        android:id="@+id/dial_pan"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1">
    </FrameLayout>     <FrameLayout
        android:id="@+id/contact_pan"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_marginLeft="@dimen/gap_12_dp"
        android:layout_weight="3"></FrameLayout>
</LinearLayout>

对应的界面代码如下:

public class DialFragment extends Fragment{

    public DialFragment() {
        // Required empty public constructor
    }     /**
     * Use this factory method to create a new instance of
     * this fragment using the provided parameters.
     *
     * @return A new instance of fragment DialFragment.
     */
    public static DialFragment newInstance() {
        DialFragment fragment = new DialFragment();
        return fragment;
    }     @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_dial, container, false);
    }     @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        addFragments();;
    }     private void addFragments() {
        FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
        transaction.replace(R.id.dial_pan, new DialPanFragment());
        VerticalGridFragment fragment = new VerticalGridFragment();
        Bundle args = new Bundle();
        args.putInt(Extra.COLUMNS, Extra.DIAL_COLUMNS);
        fragment.setArguments(args);
        transaction.replace(R.id.contact_pan, fragment);
        transaction.commit();
    } }

拨号界面被分成了两部分,一部分为拨号盘,一部分为联系人,分别占据了屏幕一份和三份,右边的联系人与主界面的好用共用了同一个Fragment,因此这里我们再看看接下来的两个界面,首先我们看看拨号盘的界面代码。

由于只做展示,因此代码写的很粗糙,界面直接写了N个按钮的代码,配置界面如下:

<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:background="@color/white_35_transparent"
                android:clickable="true"
                android:contextClickable="true"
                android:orientation="vertical"
                tools:context="im.yixin.home.dial.DialFragment">     <ImageView
        android:id="@+id/dial_icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="@dimen/gap_20_dp"
        android:focusable="true"
        android:padding="@dimen/gap_20_dp"
        android:src="@drawable/tv_call_btn_selector"/>     <LinearLayout
        android:id="@+id/input_num_line_1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_above="@id/dial_icon"
        android:baselineAligned="false"
        android:orientation="horizontal">         <RelativeLayout
            android:layout_width="0dp"
            android:layout_height="80dp"
            android:layout_weight="1"
            android:background="@drawable/keyboard_item_selector">             <ImageView
                android:id="@+id/input_key_number_null"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:contentDescription="@string/empty"/>
        </RelativeLayout>         <RelativeLayout
            android:layout_width="0dp"
            android:layout_height="80dp"
            android:layout_weight="1">             <TextView
                android:id="@+id/input_key_number_0"
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:layout_centerInParent="true"
                android:background="@drawable/keyboard_item_selector"
                android:focusable="true"
                android:gravity="center"
                android:text="0"
                android:textColor="#ffffff"
                android:textSize="30sp"/>
        </RelativeLayout>         <RelativeLayout
            android:layout_width="0dp"
            android:layout_height="80dp"
            android:layout_weight="1">             <ImageView
                android:id="@+id/input_key_number_del"
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:layout_centerInParent="true"
                android:background="@drawable/keyboard_item_selector"
                android:contentDescription="@string/empty"
                android:focusable="true"
                android:scaleType="center"
                android:src="@drawable/tv_del"/>
        </RelativeLayout>
    </LinearLayout>     <LinearLayout
        android:id="@+id/input_num_line_2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/input_num_line_1"
        android:baselineAligned="false"
        android:orientation="horizontal">         <RelativeLayout
            android:layout_width="0dp"
            android:layout_height="80dp"
            android:layout_weight="1">             <TextView
                android:id="@+id/input_key_number_7"
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:layout_centerInParent="true"
                android:background="@drawable/keyboard_item_selector"
                android:focusable="true"
                android:gravity="center"
                android:text="7"
                android:textColor="#ffffff"
                android:textSize="30sp"/>
        </RelativeLayout>         <RelativeLayout
            android:layout_width="0dp"
            android:layout_height="80dp"
            android:layout_weight="1">             <TextView
                android:id="@+id/input_key_number_8"
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:layout_centerInParent="true"
                android:background="@drawable/keyboard_item_selector"
                android:focusable="true"
                android:gravity="center"
                android:text="8"
                android:textColor="#ffffff"
                android:textSize="30sp"/>
        </RelativeLayout>         <RelativeLayout
            android:layout_width="0dp"
            android:layout_height="80dp"
            android:layout_weight="1">             <TextView
                android:id="@+id/input_key_number_9"
                android:layout_width="60dp"
                android:layout_height="60dp"
                android:layout_centerInParent="true"
                android:background="@drawable/keyboard_item_selector"
                android:focusable="true"
                android:gravity="center"
                android:text="9"
                android:textColor="#ffffff"
                android:textSize="30sp"/>
        </RelativeLayout>
    </LinearLayout>

网易云免费体验馆,0成本体验20+款云产品!

更多网易研发、产品、运营经验分享请访问网易云社区

相关文章:
【推荐】 SpringBoot入门(五)——自定义配置

最新文章

  1. 文档分享-Activiti 5.16 用户手册
  2. Spring文件上传配置
  3. windows7-SQLyog 安装图解
  4. 深入理解AOP
  5. PHP 开发社区微信服务号实战图解
  6. Paip.最佳实践-- Buildin variale 内建变量 ,魔术变量,预定义变量,系统常量,系统变量 1
  7. CSS权威指南 - 浮动和定位 1
  8. CentOS学习笔记--基本命令--文件与目录管理
  9. silverlight 控件自定义样式 实现方法
  10. 九度OJ 1118 数制转换
  11. mysqldump命令详解(转载)
  12. jquery中这句 .stop(false,true); 什么意思
  13. JavaScript忍者秘籍——驯服线程和定时器
  14. quagga源码学习--BGP协议对等体连接tcp md5签名认证选项
  15. Python中的变量
  16. SQL Server 使用问题解答(持续更新中)
  17. Apache Flink 简单安装
  18. python(Django之Logging、API认证)
  19. org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].Standard
  20. 客户端如何访问访问oracle 12c 64位的数据库

热门文章

  1. 使用Docx.dll插入图片在Centos 7 上报错:system.DllNotFound:libgdiplus.so
  2. [转]latex输入数学符号速查
  3. JAVA继承与使用
  4. 编译安装PHP-7.1.8
  5. Log4j知识汇总
  6. display:table的几个用法(元素平分宽度,垂直居中)
  7. ubuntu14.04server下安装scala+sbt工具
  8. 数据字典的设计--4.DOM对象的ajax应用
  9. 2018.2.2 java中的Date如何获取 年月日时分秒
  10. MAC 设置登录欢迎语