本文来自http://blog.csdn.net/yihongyuelan 转载请务必注明出处
本文代码以MTK平台Android 4.4为分析对象,与Google原生AOSP有些许差异,请读者知悉。
概述
之前有分析过Android 4.2的InCallScreen结构(传送门),但后面Google发布了Android 4.4即Kitkat,遂决定以之前的文章为模板,重新整理并记录。在4.4中当有来电或去电时,显示给用户的界面如图1,在4.4之前称之为InCallScreen,但在4.4之后叫做InCallActivity。在4.4中我们调出的拨号盘界面,实际为DialtactsActivity并隶属于Dialer应用。4.4 中界面分为3块,CallCardFragment、CallButtonFragment、AnswerFragment,如下所示:
图 1 InCallActivity界面(左:接通 右:来电)
InCallActivity布局分析
在InCallActivity.java中,实现了对界面的初始化,在4.4中界面的布局是通过fragment来完成的,即incall_screen.xml,代码如下:
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/main">
<!-- MTK VideoCall fragment -->
<FrameLayout
android:id="@+id/vtCallFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<LinearLayout
android:id="@+id/in_call_and_button_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/in_call_card_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<!-- CallCard fragment 用于显示联系人信息 -->
<fragment
android:name="com.android.incallui.CallCardFragment"
android:id="@+id/callCardFragment"