android M撥號盤開源之旅(二)--- 淺析撥號盤主界面

来源:http://www.cnblogs.com/lance2016/archive/2016/03/07/5252451.html
-Advertisement-
Play Games

接上篇博文:http://www.cnblogs.com/lance2016/p/5229073.html 上一節課給大家簡單介紹了下android撥號盤的工程概況,今天再向大家剖析一下主界面的佈局實現 先貼上主界面佈局: <?xml version="1.0" encoding="utf-8"?>


接上篇博文:android M撥號盤開源之旅(一)--- 初窺M撥號盤

上一節課給大家簡單介紹了下android撥號盤的工程概況,今天再向大家剖析一下主界面的佈局實現

 

先貼上主界面佈局:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/dialtacts_mainlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:focusable="true"
android:focusableInTouchMode="true"
android:clipChildren="false"
android:background="@color/background_dialer_light">
<FrameLayout
android:id="@+id/dialtacts_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false">
<!-- The main contacts grid -->
<FrameLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="@+id/dialtacts_frame"
android:clipChildren="false" />
</FrameLayout>
<FrameLayout
android:id="@+id/floating_action_button_container"
android:background="@drawable/fab_blue"
android:layout_width="@dimen/floating_action_button_width"
android:layout_height="@dimen/floating_action_button_height"
android:layout_marginBottom="@dimen/floating_action_button_margin_bottom"
android:layout_gravity="center_horizontal|bottom">
<ImageButton
android:id="@+id/floating_action_button"
android:background="@drawable/floating_action_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/action_menu_dialpad_button"
android:src="@drawable/fab_ic_dial"/>
</FrameLayout>
</FrameLayout>



 

xml比較簡單,我們看看DialtactsActivity里的實現

final ActionBar actionBar = getActionBar();
actionBar.setCustomView(R.layout.search_edittext);
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setBackgroundDrawable(null);

SearchEditTextLayout searchEditTextLayout =
(SearchEditTextLayout) actionBar.getCustomView().findViewById(R.id.search_view_container);
searchEditTextLayout.setPreImeKeyListener(mSearchEditTextLayoutListener);

mActionBarController = new ActionBarController(this, searchEditTextLayout);

菜單控制器private ActionBarController mActionBarController;

用來管理SearchEditTextLayout對象(actionbar的customview)


 

接下來是主界面fragment(快速撥號,通話記錄,聯繫人)

private ListsFragment mListsFragment;

放在dialtacts_frame容器里

getFragmentManager().beginTransaction().add(R.id.dialtacts_frame, new ListsFragment(), TAG_FAVORITES_FRAGMENT).commit();

 

全局搜索fragment private RegularSearchFragment mRegularSearchFragment;(在actionbar的edittext里輸入號碼呈現結果集的fragment)
撥號搜索fragment private SmartDialSearchFragment mSmartDialSearchFragment; (在撥號盤裡輸入號碼呈現結果集的fragment)

都放在dialtacts_frame容器里(根據是否處於搜索模式動態創建和移除)

private void enterSearchUi(boolean smartDialSearch, String query, boolean animate) 
if (smartDialSearch) {
    fragment = new SmartDialSearchFragment();
} else {
  fragment = new RegularSearchFragment();
}

transaction.add(R.id.dialtacts_frame, fragment, tag);

private void exitSearchUi() 
if (mSmartDialSearchFragment != null) {
    transaction.remove(mSmartDialSearchFragment);
}

if (mRegularSearchFragment != null) {
    transaction.remove(mRegularSearchFragment);
}


 

撥號盤fragment

protected DialpadFragment mDialpadFragment;

放在dialtacts_container容器里

if (mDialpadFragment == null) {
    mDialpadFragment = new DialpadFragment();
    ft.add(R.id.dialtacts_container, mDialpadFragment, TAG_DIALPAD_FRAGMENT);
} else {
  ft.show(mDialpadFragment);
}



 

懸浮按鈕控制器,管理懸浮按鈕事件

private FloatingActionButtonController mFloatingActionButtonController;

final View floatingActionButtonContainer = findViewById(R.id.floating_action_button_container);
ImageButton floatingActionButton = (ImageButton) findViewById(R.id.floating_action_button);
floatingActionButton.setOnClickListener(this);
mFloatingActionButtonController = new FloatingActionButtonController(this,floatingActionButtonContainer, floatingActionButton);

 

主界面容器ListsFragment mListsFragment;

自定義的TAB分頁控制項ViewPagerTabs extends HorizontalScrollView

嵌套三個子fragment:快速撥號,通話記錄,聯繫人

private SpeedDialFragment mSpeedDialFragment;
private CallLogFragment mRecentsFragment;
private AllContactsFragment mAllContactsFragment;

 

主界面的框架大致如此,各個fragment切換邏輯以及動效細節大家跟蹤代碼實現細看就明白了

時間不早了,今天的課程到此為止

github下載鏈接https://github.com/geniusgithub/AndroidDialer

apk也附在了工程主頁,大家可以先安裝體驗一下 

 

欲知後事如何,且聽藍老師下回分解

more brilliant,Please pay attention to my cnblog -->http://www.cnblogs.com/lance2016/


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 1.內置對象創建 var girl=new Object(); girl.name='hxl'; console.log(typeof girl); 2.工廠模式,寄生構造函數模式 function Person(name){ var p=new Object();//內部進行實例化 p.name=
  • package com.example.yanlei.myyk; import android.media.MediaPlayer; import android.net.Uri; import android.os.Bundle; import android.os.Environment; im
  • 分類:C#、Android、VS2015; 創建日期:2016-03-08 一、簡介 ContentProvider:內容提供程式。 Android的ContentProvider與.NET框架的EF(Entity Framework)非常類似。在EF中,每個類表示資料庫中的一個表,類中的每個屬性對...
  • 在Archive項目時,出現了“Your build settings specify a provisioning profile with the UUID “”, however, no such provisioning profile was found”的出錯。一直提示指定UUID的pr
  • Fragment 用途:在一個Activity里切換界面,切換界面時只切換Fragment裡面的內容 生命周期方法跟Activity一致,可以理解把其為就是一個Activity 定義佈局文件作為Fragment的顯示內容 //此方法返回的View就會被顯示在Fragment上 @Override p
  • 多媒體概念 文字、圖片、音頻、視頻 電腦圖片大小的計算 圖片大小 = 圖片的總像素 * 每個像素占用的大小 單色圖:每個像素占用1/8個位元組 16色圖:每個像素占用1/2個位元組 256色圖:每個像素占用1個位元組 24點陣圖:每個像素占用3個位元組 載入大圖片到記憶體 Android系統以ARGB表示每個
  • 內容提供者 應用的資料庫是不允許其他應用訪問的 內容提供者的作用就是讓別的應用訪問到你的資料庫 自定義內容提供者,繼承ContentProvider類,重寫增刪改查方法,在方法中寫增刪改查資料庫的代碼,舉例增方法 @Override public Uri insert(Uri uri, Conten
  • 創建第二個Activity 需要在清單文件中為其配置一個activity標簽 標簽中如果帶有這個子節點,則會在系統中多創建一個快捷圖標 <intent-filter> <action android:name="android.intent.action.MAIN" /> <category and
一周排行
    -Advertisement-
    Play Games
  • 示例項目結構 在 Visual Studio 中創建一個 WinForms 應用程式後,項目結構如下所示: MyWinFormsApp/ │ ├───Properties/ │ └───Settings.settings │ ├───bin/ │ ├───Debug/ │ └───Release/ ...
  • [STAThread] 特性用於需要與 COM 組件交互的應用程式,尤其是依賴單線程模型(如 Windows Forms 應用程式)的組件。在 STA 模式下,線程擁有自己的消息迴圈,這對於處理用戶界面和某些 COM 組件是必要的。 [STAThread] static void Main(stri ...
  • 在WinForm中使用全局異常捕獲處理 在WinForm應用程式中,全局異常捕獲是確保程式穩定性的關鍵。通過在Program類的Main方法中設置全局異常處理,可以有效地捕獲並處理未預見的異常,從而避免程式崩潰。 註冊全局異常事件 [STAThread] static void Main() { / ...
  • 前言 給大家推薦一款開源的 Winform 控制項庫,可以幫助我們開發更加美觀、漂亮的 WinForm 界面。 項目介紹 SunnyUI.NET 是一個基於 .NET Framework 4.0+、.NET 6、.NET 7 和 .NET 8 的 WinForm 開源控制項庫,同時也提供了工具類庫、擴展 ...
  • 說明 該文章是屬於OverallAuth2.0系列文章,每周更新一篇該系列文章(從0到1完成系統開發)。 該系統文章,我會儘量說的非常詳細,做到不管新手、老手都能看懂。 說明:OverallAuth2.0 是一個簡單、易懂、功能強大的許可權+可視化流程管理系統。 有興趣的朋友,請關註我吧(*^▽^*) ...
  • 一、下載安裝 1.下載git 必須先下載並安裝git,再TortoiseGit下載安裝 git安裝參考教程:https://blog.csdn.net/mukes/article/details/115693833 2.TortoiseGit下載與安裝 TortoiseGit,Git客戶端,32/6 ...
  • 前言 在項目開發過程中,理解數據結構和演算法如同掌握蓋房子的秘訣。演算法不僅能幫助我們編寫高效、優質的代碼,還能解決項目中遇到的各種難題。 給大家推薦一個支持C#的開源免費、新手友好的數據結構與演算法入門教程:Hello演算法。 項目介紹 《Hello Algo》是一本開源免費、新手友好的數據結構與演算法入門 ...
  • 1.生成單個Proto.bat內容 @rem Copyright 2016, Google Inc. @rem All rights reserved. @rem @rem Redistribution and use in source and binary forms, with or with ...
  • 一:背景 1. 講故事 前段時間有位朋友找到我,說他的窗體程式在客戶這邊出現了卡死,讓我幫忙看下怎麼回事?dump也生成了,既然有dump了那就上 windbg 分析吧。 二:WinDbg 分析 1. 為什麼會卡死 窗體程式的卡死,入口門檻很低,後續往下分析就不一定了,不管怎麼說先用 !clrsta ...
  • 前言 人工智慧時代,人臉識別技術已成為安全驗證、身份識別和用戶交互的關鍵工具。 給大家推薦一款.NET 開源提供了強大的人臉識別 API,工具不僅易於集成,還具備高效處理能力。 本文將介紹一款如何利用這些API,為我們的項目添加智能識別的亮點。 項目介紹 GitHub 上擁有 1.2k 星標的 C# ...