Android phone 拨号UI

界面加载过程

DialtactsActivity.java

[java] view plain copy print ?
  1. protected void onCreate(Bundle icicle) {  
  2.     this.setTheme(R.style.DialtactsTheme);  
  3.     super.onCreate(icicle);  
  4.     final Intent intent = getIntent();  
  5.     fixIntent(intent);  
  6.     //解析布局文件   
  7.     DialpadGlobals globals = DialpadGlobals.getGlobals(this);  
  8.     try {  
  9.         //得到mDialpadActivityView ---dialtacts_activity.xml  
  10.         View view = globals.getDialpadActivityView();  
  11.         if(view != null){  
  12.             Log.d(TAG, "get view from application");  
  13.             setContentView(view);  
  14.         }else{  
  15.             tryToSetContentView();  
  16.         }  
  17.     } catch (Exception e) {  
  18.         tryToSetContentView();  
  19.     }  
  20.     mContactListFilterController = globals.getContactListFilterController();  
  21.     mContactListFilterController.addListener(mContactListFilterListener);  
  22.     View viewDialtacts = findViewById(R.id.dialtacts_frame);  
  23.     if (viewDialtacts != null && mFirstLayoutListener != null) {  
  24.         viewDialtacts.addOnLayoutChangeListener(mFirstLayoutListener);  
  25.     }  
  26.     //设置滚动页ViewPages   
  27.     mViewPager = (ViewPager) findViewById(R.id.pager);  
  28.     if (mViewPager != null) {  
  29.         mViewPager.setAdapter(new ViewPagerAdapter(getFragmentManager()));  
  30.         if (mPageChangeListener != null) {  
  31.             mViewPager.setOnPageChangeListener(mPageChangeListener);  
  32.         }  
  33.         mViewPager.setOffscreenPageLimit(2);  
  34.     }  
  35.     //设置滚动页的tab标签属性   
  36.     int tabHeight = (int) getResources().getDimensionPixelSize(R.dimen.universe_ui_tab_height);  
  37.     Log.d(TAG,"tabHeight="+tabHeight);  
  38.     getActionBar().setAlternativeTabStyle(true);  
  39.     getActionBar().setTabHeight(tabHeight);  
  40.     getActionBar().setLogo(R.mipmap.ic_launcher_contacts);  
  41.   
  42.     // Do same width calculation as ActionBar does  
  43.     DisplayMetrics dm = getResources().getDisplayMetrics();  
  44.     int minCellSize = getResources().getDimensionPixelSize(R.dimen.fake_menu_button_min_width);  
  45.     int cellCount = dm.widthPixels / minCellSize;  
  46.     int fakeMenuItemWidth = dm.widthPixels / cellCount;  
  47.     if (DEBUG) Log.d(TAG, "The size of fake menu buttons (in pixel): " + fakeMenuItemWidth);  
  48.     //设置按钮mMenuButton   
  49.     mMenuButton = findViewById(R.id.overflow_menu);  
  50.     if (mMenuButton != null) {  
  51.         mMenuButton.setMinimumWidth(fakeMenuItemWidth);  
  52.         if (ViewConfiguration.get(this).hasPermanentMenuKey()) {  
  53.             // This is required for dialpad button's layout, so must not use GONE here.  
  54.             mMenuButton.setVisibility(View.INVISIBLE);  
  55.         } else {  
  56.             mMenuButton.setOnClickListener(this);  
  57.         }  
  58.     }  
  59.     //设置按钮mSearchButton   
  60.     mSearchButton = findViewById(R.id.searchButton);  
  61.     if (mSearchButton != null) {  
  62.         mSearchButton.setMinimumWidth(fakeMenuItemWidth);  
  63.         mSearchButton.setOnClickListener(this);  
  64.     }  
  65.     //添加Dialer、CallLog、Contacts、Favorites标签  
  66.     setupDialer();  
  67.     setupCallLog();  
  68.     if(UniverseUtils.UNIVERSEUI_SUPPORT){  
  69.         setupAllContacts();  
  70.     }  
  71.     setupFavorites();  
  72.     getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);  
  73.     getActionBar().setDisplayShowTitleEnabled(false);  
  74.     getActionBar().setDisplayShowHomeEnabled(false);  
  75.     // Load the last manually loaded tab  
  76.     mPrefs = PreferenceManager.getDefaultSharedPreferences(this);  
  77.     setCurrentTab(intent);  
  78.     if (UI.FILTER_CONTACTS_ACTION.equals(intent.getAction()) && icicle == null) {  
  79.         setupFilterText(intent);  
  80.     }  
  81.     if(UniverseUtils.UNIVERSEUI_SUPPORT){  
  82.         mViewPager.setVisibility(View.VISIBLE);  
  83.     }  
  84. }  
protected void onCreate(Bundle icicle) {
	this.setTheme(R.style.DialtactsTheme);
	super.onCreate(icicle);
	final Intent intent = getIntent();
	fixIntent(intent);
	//解析布局文件
	DialpadGlobals globals = DialpadGlobals.getGlobals(this);
	try {
		//得到mDialpadActivityView ---dialtacts_activity.xml
		View view = globals.getDialpadActivityView();
		if(view != null){
			Log.d(TAG, "get view from application");
			setContentView(view);
		}else{
			tryToSetContentView();
		}
	} catch (Exception e) {
		tryToSetContentView();
	}
	mContactListFilterController = globals.getContactListFilterController();
	mContactListFilterController.addListener(mContactListFilterListener);
	View viewDialtacts = findViewById(R.id.dialtacts_frame);
	if (viewDialtacts != null && mFirstLayoutListener != null) {
		viewDialtacts.addOnLayoutChangeListener(mFirstLayoutListener);
	}
	//设置滚动页ViewPages
	mViewPager = (ViewPager) findViewById(R.id.pager);
	if (mViewPager != null) {
		mViewPager.setAdapter(new ViewPagerAdapter(getFragmentManager()));
		if (mPageChangeListener != null) {
			mViewPager.setOnPageChangeListener(mPageChangeListener);
		}
		mViewPager.setOffscreenPageLimit(2);
	}
	//设置滚动页的tab标签属性
	int tabHeight = (int) getResources().getDimensionPixelSize(R.dimen.universe_ui_tab_height);
	Log.d(TAG,"tabHeight="+tabHeight);
	getActionBar().setAlternativeTabStyle(true);
	getActionBar().setTabHeight(tabHeight);
	getActionBar().setLogo(R.mipmap.ic_launcher_contacts);

	// Do same width calculation as ActionBar does
	DisplayMetrics dm = getResources().getDisplayMetrics();
	int minCellSize = getResources().getDimensionPixelSize(R.dimen.fake_menu_button_min_width);
	int cellCount = dm.widthPixels / minCellSize;
	int fakeMenuItemWidth = dm.widthPixels / cellCount;
	if (DEBUG) Log.d(TAG, "The size of fake menu buttons (in pixel): " + fakeMenuItemWidth);
	//设置按钮mMenuButton
	mMenuButton = findViewById(R.id.overflow_menu);
	if (mMenuButton != null) {
		mMenuButton.setMinimumWidth(fakeMenuItemWidth);
		if (ViewConfiguration.get(this).hasPermanentMenuKey()) {
			// This is required for dialpad button's layout, so must not use GONE here.
			mMenuButton.setVisibility(View.INVISIBLE);
		} else {
			mMenuButton.setOnClickListener(this);
		}
	}
	//设置按钮mSearchButton
	mSearchButton = findViewById(R.id.searchButton);
	if (mSearchButton != null) {
		mSearchButton.setMinimumWidth(fakeMenuItemWidth);
		mSearchButton.setOnClickListener(this);
	}
	//添加Dialer、CallLog、Contacts、Favorites标签
	setupDialer();
	setupCallLog();
	if(UniverseUtils.UNIVERSEUI_SUPPORT){
		setupAllContacts();
	}
	setupFavorites();
	getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
	getActionBar().setDisplayShowTitleEnabled(false);
	getActionBar().setDisplayShowHomeEnabled(false);
	// Load the last manually loaded tab
	mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
	setCurrentTab(intent);
	if (UI.FILTER_CONTACTS_ACTION.equals(intent.getAction()) && icicle == null) {
		setupFilterText(intent);
	}
	if(UniverseUtils.UNIVERSEUI_SUPPORT){
		mViewPager.setVisibility(View.VISIBLE);
	}
}

1.布局文件解析

在DialtactsActivity的onCreate函数中通过DialpadGlobals加载布局文件,以单例模式获取DialpadGlobals实例对象:

DialpadGlobals.java

[html] view plain copy print ?
  1. public static DialpadGlobals getGlobals(Context context) {  
  2.     if (INSTANCE == null) {  
  3.         INSTANCE = new DialpadGlobals(context);  
  4.     }  
  5.     return INSTANCE;  
  6. }  
public static DialpadGlobals getGlobals(Context context) {
	if (INSTANCE == null) {
		INSTANCE = new DialpadGlobals(context);
	}
	return INSTANCE;
}

DialpadGlobals对象的构造过程:

[java] view plain copy print ?
  1. private DialpadGlobals(Context context) {  
  2.     mContext = context;  
  3.     mInflater = LayoutInflater.from(context);  
  4.     Log.d(TAG, "The Optimization do not support UUI.");  
  5.     initGlobalsTouchLocal();  
  6.     initGlobalsNotTouchLocal();  
  7.     try {  
  8.         Class.forName("com.android.contacts.activities.DialtactsActivity");  
  9.         Class.forName("com.android.contacts.dialpad.DialpadFragment");  
  10.         Class.forName("com.android.contacts.calllog.CallLogFragment");  
  11.     } catch (ClassNotFoundException e) {  
  12.         e.printStackTrace();  
  13.     }  
  14.     IntentFilter filter = new IntentFilter();  
  15.     filter.addAction(Intent.ACTION_LOCALE_CHANGED);  
  16.     mContext.registerReceiver(mBroadcast, filter);  
  17. }  
private DialpadGlobals(Context context) {
	mContext = context;
	mInflater = LayoutInflater.from(context);
	Log.d(TAG, "The Optimization do not support UUI.");
	initGlobalsTouchLocal();
	initGlobalsNotTouchLocal();
	try {
		Class.forName("com.android.contacts.activities.DialtactsActivity");
		Class.forName("com.android.contacts.dialpad.DialpadFragment");
		Class.forName("com.android.contacts.calllog.CallLogFragment");
	} catch (ClassNotFoundException e) {
		e.printStackTrace();
	}
	IntentFilter filter = new IntentFilter();
	filter.addAction(Intent.ACTION_LOCALE_CHANGED);
	mContext.registerReceiver(mBroadcast, filter);
}

函数首先加载各个布局文件,然后加载相应的类。

[java] view plain copy print ?
  1. private void initGlobalsTouchLocal() {  
  2.     Resources resource = mContext.getResources();  
  3.     mDialpadActivityView = mInflater.inflate(R.layout.dialtacts_activity, null);  
  4.     mDialpadFragmentView = mInflater.inflate(R.layout.dialpad_list_fragment, null);  
  5.     mCaLLLogFragmentView = mInflater.inflate(R.layout.call_log_fragment, null);  
  6.   
  7.     // pre load DialpadFragment  
  8.     mCurrentCountryIso = ContactsUtils.getCurrentCountryIso(mContext);  
  9.     mProhibitedPhoneNumberRegexp = resource.getString(R.string.config_prohibited_phone_number_regexp);  
  10. }  
private void initGlobalsTouchLocal() {
	Resources resource = mContext.getResources();
	mDialpadActivityView = mInflater.inflate(R.layout.dialtacts_activity, null);
	mDialpadFragmentView = mInflater.inflate(R.layout.dialpad_list_fragment, null);
	mCaLLLogFragmentView = mInflater.inflate(R.layout.call_log_fragment, null);

	// pre load DialpadFragment
	mCurrentCountryIso = ContactsUtils.getCurrentCountryIso(mContext);
	mProhibitedPhoneNumberRegexp = resource.getString(R.string.config_prohibited_phone_number_regexp);
}

这样电话拨号界面就保存在DialpadGlobals类的成员mDialpadActivityView中,通过View view = globals.getDialpadActivityView()就可以得到拨号视图了。

dialtacts_activity.xml布局

[html] view plain copy print ?
  1. <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  2.     android:layout_width="match_parent"  
  3.     android:layout_height="match_parent"  
  4.     android:paddingTop="?android:attr/actionBarSize"  
  5.     android:id="@+id/dialtacts_frame">  
  6.     <android.support.v4.view.ViewPager  
  7.         android:id="@+id/pager"  
  8.         android:layout_width="match_parent"  
  9.         android:layout_height="match_parent" />  
  10.     <ImageButton  
  11.          android:id="@+id/searchButton"  
  12.          android:layout_width="wrap_content"  
  13.          android:layout_height="?android:attr/actionBarSize"  
  14.          android:layout_gravity="bottom|left"  
  15.          android:state_enabled="false"  
  16.          android:background="?android:attr/selectableItemBackground"  
  17.          android:contentDescription="@string/description_search_button"  
  18.          android:src="@drawable/ic_dial_action_search"/>  
  19.     <ImageButton  
  20.          android:id="@+id/overflow_menu"  
  21.          android:layout_width="wrap_content"  
  22.          android:layout_height="?android:attr/actionBarSize"  
  23.          android:layout_gravity="bottom|right"  
  24.          android:src="@drawable/ic_menu_overflow"  
  25.          android:contentDescription="@string/action_menu_overflow_description"  
  26.          android:nextFocusLeft="@id/digits"  
  27.          android:background="?android:attr/selectableItemBackground"/>  
  28. </FrameLayout>  
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingTop="?android:attr/actionBarSize"
    android:id="@+id/dialtacts_frame">
    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
    <ImageButton
         android:id="@+id/searchButton"
         android:layout_width="wrap_content"
         android:layout_height="?android:attr/actionBarSize"
         android:layout_gravity="bottom|left"
         android:state_enabled="false"
         android:background="?android:attr/selectableItemBackground"
         android:contentDescription="@string/description_search_button"
         android:src="@drawable/ic_dial_action_search"/>
    <ImageButton
         android:id="@+id/overflow_menu"
         android:layout_width="wrap_content"
         android:layout_height="?android:attr/actionBarSize"
         android:layout_gravity="bottom|right"
         android:src="@drawable/ic_menu_overflow"
         android:contentDescription="@string/action_menu_overflow_description"
         android:nextFocusLeft="@id/digits"
         android:background="?android:attr/selectableItemBackground"/>
</FrameLayout>

2.滑动页监听设置

[java] view plain copy print ?
  1. //设置滚动页ViewPages   
  2. mViewPager = (ViewPager) findViewById(R.id.pager);  
  3. if (mViewPager != null) {  
  4.     mViewPager.setAdapter(new ViewPagerAdapter(getFragmentManager()));  
  5.     if (mPageChangeListener != null) {  
  6.         mViewPager.setOnPageChangeListener(mPageChangeListener);  
  7.     }  
  8.     mViewPager.setOffscreenPageLimit(2);  
  9. }  
//设置滚动页ViewPages
mViewPager = (ViewPager) findViewById(R.id.pager);
if (mViewPager != null) {
	mViewPager.setAdapter(new ViewPagerAdapter(getFragmentManager()));
	if (mPageChangeListener != null) {
		mViewPager.setOnPageChangeListener(mPageChangeListener);
	}
	mViewPager.setOffscreenPageLimit(2);
}

滑动适配器

[java] view plain copy print ?
  1. public class ViewPagerAdapter extends FragmentPagerAdapter {  
  2.     public ViewPagerAdapter(FragmentManager fm) {  
  3.         super(fm);  
  4.     }  
  5.   
  6.     @Override  
  7.     public Fragment getItem(int position) {  
  8.         switch (position) {  
  9.             //拨号界面   
  10.             case TAB_INDEX_DIALER_NEWUI:  
  11.                 return new DialpadFragment();  
  12.             //联系人界面   
  13.             case TAB_INDEX_CONTACTS_NEWUI:  
  14.                 mAllFragment = new DefaultContactBrowseListFragment();  
  15.                 mAllFragment.mIsDisplayInDialer = true;  
  16.                 return mAllFragment;  
  17.             //通话记录界面   
  18.             case TAB_INDEX_CALL_LOG_NEWUI:  
  19.                 return new CallLogFragment();  
  20.             //收藏界面   
  21.             case TAB_INDEX_FAVORITES_NEWUI:  
  22.                 return new PhoneFavoriteFragment();  
  23.             default:  
  24.                 throw new IllegalStateException("No fragment at position " + position);  
  25.         }  
  26.     }  
  27.   
  28.     @Override  
  29.     public void setPrimaryItem(ViewGroup container, int position, Object object) {  
  30.         if (DEBUG) {  
  31.             Log.d(TAG, "FragmentPagerAdapter#setPrimaryItem(), position: " + position);  
  32.         }  
  33.         super.setPrimaryItem(container, position, object);  
  34.     }  
  35.   
  36.     @Override  
  37.     public int getCount() {  
  38.         if(UniverseUtils.UNIVERSEUI_SUPPORT){  
  39.             return TAB_INDEX_COUNT_NEWUI;  
  40.         } else {  
  41.             return TAB_INDEX_COUNT;  
  42.         }  
  43.     }  
  44. }  
public class ViewPagerAdapter extends FragmentPagerAdapter {
	public ViewPagerAdapter(FragmentManager fm) {
		super(fm);
	}

	@Override
	public Fragment getItem(int position) {
		switch (position) {
			//拨号界面
			case TAB_INDEX_DIALER_NEWUI:
				return new DialpadFragment();
			//联系人界面
			case TAB_INDEX_CONTACTS_NEWUI:
				mAllFragment = new DefaultContactBrowseListFragment();
				mAllFragment.mIsDisplayInDialer = true;
				return mAllFragment;
			//通话记录界面
			case TAB_INDEX_CALL_LOG_NEWUI:
				return new CallLogFragment();
			//收藏界面
			case TAB_INDEX_FAVORITES_NEWUI:
				return new PhoneFavoriteFragment();
			default:
				throw new IllegalStateException("No fragment at position " + position);
		}
	}

	@Override
	public void setPrimaryItem(ViewGroup container, int position, Object object) {
		if (DEBUG) {
			Log.d(TAG, "FragmentPagerAdapter#setPrimaryItem(), position: " + position);
		}
		super.setPrimaryItem(container, position, object);
	}

	@Override
	public int getCount() {
		if(UniverseUtils.UNIVERSEUI_SUPPORT){
			return TAB_INDEX_COUNT_NEWUI;
		} else {
			return TAB_INDEX_COUNT;
		}
	}
}

各个视图类之间的关系图:

Android phone 拨号UI_第1张图片

3.滑动标签设置

[java] view plain copy print ?
  1. setupDialer();  
  2. setupCallLog();  
  3. setupAllContacts();  
  4. setupFavorites();  
setupDialer();
setupCallLog();
setupAllContacts();
setupFavorites();

拨号标签添加

[java] view plain copy print ?
  1. private void setupDialer() {  
  2.     final Tab tab = getActionBar().newTab();  
  3.     LayoutInflater inflater = getLayoutInflater();    
  4.     View view = inflater.inflate(R.layout.dialtacts_tab_new_ui, null);    
  5.     ImageView dialView =  (ImageView)view.findViewById(R.id.tab_icon);   
  6.     if(dialView != null){  
  7.         dialView.setImageResource(R.drawable.ic_tab_dialer_newui);  
  8.     }  
  9.     TextView dialText = (TextView) view.findViewById(R.id.tab_text);  
  10.     if(dialText!=null){  
  11.         dialText.setText(R.string.dialerIconLabel);  
  12.     }  
  13.     tab.setCustomView(view);  
  14.     tab.setTabListener(mTabListener);  
  15.     getActionBar().addTab(tab);  
  16. }  
private void setupDialer() {
	final Tab tab = getActionBar().newTab();
	LayoutInflater inflater = getLayoutInflater();  
	View view = inflater.inflate(R.layout.dialtacts_tab_new_ui, null);  
	ImageView dialView =  (ImageView)view.findViewById(R.id.tab_icon); 
	if(dialView != null){
		dialView.setImageResource(R.drawable.ic_tab_dialer_newui);
	}
	TextView dialText = (TextView) view.findViewById(R.id.tab_text);
	if(dialText!=null){
		dialText.setText(R.string.dialerIconLabel);
	}
	tab.setCustomView(view);
	tab.setTabListener(mTabListener);
	getActionBar().addTab(tab);
}

通话记录标签添加

[java] view plain copy print ?
  1. private void setupCallLog() {  
  2.     final Tab tab = getActionBar().newTab();  
  3.     LayoutInflater inflater = getLayoutInflater();    
  4.     View view = inflater.inflate(R.layout.dialtacts_tab_new_ui, null);    
  5.     ImageView dialView =  (ImageView)view.findViewById(R.id.tab_icon);   
  6.     if(dialView != null){  
  7.         dialView.setImageResource(R.drawable.ic_tab_recent_newui);  
  8.     }  
  9.     TextView dialText = (TextView) view.findViewById(R.id.tab_text);  
  10.     if(dialText!=null){  
  11.         dialText.setText(R.string.recentCallsIconLabel);  
  12.     }  
  13.     tab.setCustomView(view);  
  14.     tab.setTabListener(mTabListener);  
  15.     getActionBar().addTab(tab);  
  16. }  
private void setupCallLog() {
	final Tab tab = getActionBar().newTab();
	LayoutInflater inflater = getLayoutInflater();  
	View view = inflater.inflate(R.layout.dialtacts_tab_new_ui, null);  
	ImageView dialView =  (ImageView)view.findViewById(R.id.tab_icon); 
	if(dialView != null){
		dialView.setImageResource(R.drawable.ic_tab_recent_newui);
	}
	TextView dialText = (TextView) view.findViewById(R.id.tab_text);
	if(dialText!=null){
		dialText.setText(R.string.recentCallsIconLabel);
	}
	tab.setCustomView(view);
	tab.setTabListener(mTabListener);
	getActionBar().addTab(tab);
}

收藏标签添加

[java] view plain copy print ?
  1. private void setupFavorites() {  
  2.     final Tab tab = getActionBar().newTab();  
  3.     LayoutInflater inflater = getLayoutInflater();    
  4.     View view = inflater.inflate(R.layout.dialtacts_tab_new_ui, null);    
  5.     ImageView dialView =  (ImageView)view.findViewById(R.id.tab_icon);   
  6.     if(dialView != null){  
  7.         dialView.setImageResource(R.drawable.ic_tab_starred_newui);  
  8.     }  
  9.     TextView dialText = (TextView) view.findViewById(R.id.tab_text);  
  10.     if(dialText!=null){  
  11.         dialText.setText(R.string.contactsFavoritesLabel);  
  12.     }  
  13.     tab.setCustomView(view);  
  14.     tab.setTabListener(mTabListener);  
  15.     getActionBar().addTab(tab);  
  16. }  
private void setupFavorites() {
	final Tab tab = getActionBar().newTab();
	LayoutInflater inflater = getLayoutInflater();  
	View view = inflater.inflate(R.layout.dialtacts_tab_new_ui, null);  
	ImageView dialView =  (ImageView)view.findViewById(R.id.tab_icon); 
	if(dialView != null){
		dialView.setImageResource(R.drawable.ic_tab_starred_newui);
	}
	TextView dialText = (TextView) view.findViewById(R.id.tab_text);
	if(dialText!=null){
		dialText.setText(R.string.contactsFavoritesLabel);
	}
	tab.setCustomView(view);
	tab.setTabListener(mTabListener);
	getActionBar().addTab(tab);
}


联系人标签添加

[java] view plain copy print ?
  1. private void setupAllContacts() {  
  2.     final Tab tab = getActionBar().newTab();  
  3.     LayoutInflater inflater = getLayoutInflater();    
  4.     View view = inflater.inflate(R.layout.dialtacts_tab_new_ui, null);    
  5.     ImageView dialView =  (ImageView)view.findViewById(R.id.tab_icon);   
  6.     if(dialView != null){  
  7.         dialView.setImageResource(R.drawable.ic_tab_all_newui);  
  8.     }  
  9.     TextView dialText = (TextView) view.findViewById(R.id.tab_text);  
  10.     if(dialText!=null){  
  11.         dialText.setText(R.string.people);  
  12.     }  
  13.     tab.setCustomView(view);  
  14.     tab.setTabListener(mTabListener);  
  15.     getActionBar().addTab(tab);  
  16. }  
private void setupAllContacts() {
	final Tab tab = getActionBar().newTab();
	LayoutInflater inflater = getLayoutInflater();  
	View view = inflater.inflate(R.layout.dialtacts_tab_new_ui, null);  
	ImageView dialView =  (ImageView)view.findViewById(R.id.tab_icon); 
	if(dialView != null){
		dialView.setImageResource(R.drawable.ic_tab_all_newui);
	}
	TextView dialText = (TextView) view.findViewById(R.id.tab_text);
	if(dialText!=null){
		dialText.setText(R.string.people);
	}
	tab.setCustomView(view);
	tab.setTabListener(mTabListener);
	getActionBar().addTab(tab);
}


拨号界面

Android phone 拨号UI_第2张图片

拨号视图加载过程:

DialpadFragment.java

[java] view plain copy print ?
  1. public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {  
  2.     //调用父类DialMatchFragment的onCreateView   
  3.     View fragmentView = super.onCreateView(inflater ,container ,savedState);  
  4.     // Load up the resources for the text field.  
  5.     Resources r = getResources();  
  6.     mAdditionalButtonsRow = fragmentView.findViewById(R.id.dialpadAdditionalButtons);  
  7.     mDialpad = fragmentView.findViewById(R.id.dialpad_container);  // This is null in landscape mode.  
  8.     mDigitsContainer = fragmentView.findViewById(R.id.digits_container);  
  9.     mDigits = (EditText) fragmentView.findViewById(R.id.digits);  
  10.   
  11.     if(mDigits != null){  
  12.         mDigits.setSingleLine();  
  13.         mDigits.setKeyListener(DialerKeyListener.getInstance());  
  14.         mDigits.setOnClickListener(this);  
  15.         mDigits.setOnKeyListener(this);  
  16.         mDigits.setOnLongClickListener(this);  
  17.         mDigits.addTextChangedListener(this);  
  18.     }  
  19.     ...  
  20.     return fragmentView;  
  21. }  
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
	//调用父类DialMatchFragment的onCreateView
	View fragmentView = super.onCreateView(inflater ,container ,savedState);
	// Load up the resources for the text field.
	Resources r = getResources();
	mAdditionalButtonsRow = fragmentView.findViewById(R.id.dialpadAdditionalButtons);
	mDialpad = fragmentView.findViewById(R.id.dialpad_container);  // This is null in landscape mode.
	mDigitsContainer = fragmentView.findViewById(R.id.digits_container);
	mDigits = (EditText) fragmentView.findViewById(R.id.digits);

	if(mDigits != null){
		mDigits.setSingleLine();
		mDigits.setKeyListener(DialerKeyListener.getInstance());
		mDigits.setOnClickListener(this);
		mDigits.setOnKeyListener(this);
		mDigits.setOnLongClickListener(this);
		mDigits.addTextChangedListener(this);
	}
	...
	return fragmentView;
}

父类DialMatchFragment的onCreateView函数实现

[java] view plain copy print ?
  1. public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {  
  2.     mView = inflateView(inflater, container);  
  3.     mListView = (ListView) mView.findViewById(android.R.id.list);  
  4.     if (mListView == null) {  
  5.         throw new RuntimeException(  
  6.                 "Your content must have a ListView whose id attribute is android.R.id.list'");  
  7.     }  
  8.   
  9.     View emptyView = mView.findViewById(com.android.internal.R.id.empty);  
  10.     if (emptyView != null) {  
  11.         mListView.setEmptyView(emptyView);  
  12.         if (emptyView instanceof ContactListEmptyView) {  
  13.             mEmptyView = (ContactListEmptyView) emptyView;  
  14.         }  
  15.     }  
  16.     ...  
  17.     return mView;  
  18. }  
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	mView = inflateView(inflater, container);
	mListView = (ListView) mView.findViewById(android.R.id.list);
	if (mListView == null) {
		throw new RuntimeException(
				"Your content must have a ListView whose id attribute is android.R.id.list'");
	}

	View emptyView = mView.findViewById(com.android.internal.R.id.empty);
	if (emptyView != null) {
		mListView.setEmptyView(emptyView);
		if (emptyView instanceof ContactListEmptyView) {
			mEmptyView = (ContactListEmptyView) emptyView;
		}
	}
	...
	return mView;
}

调用该类的inflateView函数来加载布局,该函数在DialMatchFragment的子类中实现
DialpadFragment.java

[java] view plain copy print ?
  1. protected View inflateView(LayoutInflater inflater, ViewGroup container) {  
  2.     DialpadGlobals globals = DialpadGlobals.getGlobals(getActivity());  
  3.     View view = globals.getDialpadFragmentView();  
  4.     if (view != null) {  
  5.         Log.d(TAG, "get view from application");  
  6.         return view;  
  7.     } else {  
  8.         return inflater.inflate(R.layout.dialpad_list_fragment, null);  
  9.     }  
  10. }  
protected View inflateView(LayoutInflater inflater, ViewGroup container) {
	DialpadGlobals globals = DialpadGlobals.getGlobals(getActivity());
	View view = globals.getDialpadFragmentView();
	if (view != null) {
		Log.d(TAG, "get view from application");
		return view;
	} else {
		return inflater.inflate(R.layout.dialpad_list_fragment, null);
	}
}

DialpadFragment布局dialpad_list_fragment_ui.xml

[html] view plain copy print ?
  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  2.     android:id="@+id/top"  
  3.     android:layout_width="match_parent"  
  4.     android:layout_height="match_parent"  
  5.     android:orientation="vertical"  
  6.     android:background="@android:color/transparent"  
  7.     android:layout_alignParentTop="true"  
  8.     android:paddingLeft="@dimen/dialpad_horizontal_margin"  
  9.     android:paddingRight="@dimen/dialpad_horizontal_margin" >  
  10.     <FrameLayout  
  11.         android:id="@+id/showdial"  
  12.         android:layout_width="fill_parent"  
  13.         android:layout_height="fill_parent"  
  14.         android:layout_alignParentTop="true"  
  15.         android:background="@android:color/transparent"  
  16.         android:layout_marginBottom="59dip">  
  17.         <include  
  18.             android:id="@+id/account_filter_header_container"  
  19.             layout="@layout/account_filter_header" />  
  20.         <include layout="@layout/dialpad_add_contacts_newui"/>  
  21.           
  22.         <View  
  23.             android:id="@+id/dialpad_background"  
  24.             android:layout_width="match_parent"  
  25.             android:layout_height="match_parent"  
  26.             android:visibility="visible"  
  27.             android:background="@drawable/dialpad_list_bg_sprd"/>  
  28.         <ListView  
  29.             android:id="@android:id/list"  
  30.             android:layout_width="match_parent"  
  31.             android:layout_height="match_parent"  
  32.             android:layout_marginRight="?attr/contact_browser_list_padding_right"  
  33.             android:layout_weight="1"  
  34.             android:fadingEdge="none"  
  35.             android:divider="@null"  
  36.             android:paddingLeft="?attr/contact_browser_list_padding_left"  
  37.             android:paddingTop="?attr/contact_browser_list_padding_left"  
  38.             android:background="@drawable/dialpad_list_bg_sprd"  
  39.             android:fastScrollEnabled="true" />  
  40.         <ViewStub  
  41.             android:id="@+id/footer_stub"  
  42.             android:layout_width="fill_parent"  
  43.             android:layout_height="wrap_content"  
  44.             android:layout="@layout/footer_panel" />  
  45.         <LinearLayout  
  46.             android:id="@+id/maindial"  
  47.             android:layout_width="match_parent"  
  48.             android:layout_height="match_parent"  
  49.             android:layout_marginTop="95dip"  
  50.             android:layout_alignParentBottom="true"  
  51.             android:background="@android:color/transparent"  
  52.             android:orientation="vertical" >  
  53.             <View  
  54.                 android:layout_width="match_parent"  
  55.                 android:layout_height="1dip"  
  56.                 android:background="@android:color/transparent" />  
  57.             <!-- 按键部分 -->  
  58.             <include layout="@layout/dialpad_new_ui" />  
  59.   
  60.             <!-- 拨号按钮 -->  
  61.             <include layout="@layout/dialpad_additional_buttons_dial_new_ui" />  
  62.         </LinearLayout>  
  63.     </FrameLayout>  
  64.     <ListView  
  65.         android:id="@+id/dialpadChooser"  
  66.         android:layout_width="match_parent"  
  67.         android:background="@drawable/dialpad_list_bg_sprd"   
  68.         android:layout_height="1dip"  
  69.         android:layout_weight="1" />  
  70. </LinearLayout>  
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/top"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@android:color/transparent"
    android:layout_alignParentTop="true"
    android:paddingLeft="@dimen/dialpad_horizontal_margin"
    android:paddingRight="@dimen/dialpad_horizontal_margin" >
    <FrameLayout
        android:id="@+id/showdial"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentTop="true"
        android:background="@android:color/transparent"
        android:layout_marginBottom="59dip">
        <include
            android:id="@+id/account_filter_header_container"
            layout="@layout/account_filter_header" />
        <include layout="@layout/dialpad_add_contacts_newui"/>
        
		<View
			android:id="@+id/dialpad_background"
			android:layout_width="match_parent"
			android:layout_height="match_parent"
			android:visibility="visible"
			android:background="@drawable/dialpad_list_bg_sprd"/>
        <ListView
            android:id="@android:id/list"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginRight="?attr/contact_browser_list_padding_right"
            android:layout_weight="1"
            android:fadingEdge="none"
            android:divider="@null"
            android:paddingLeft="?attr/contact_browser_list_padding_left"
            android:paddingTop="?attr/contact_browser_list_padding_left"
            android:background="@drawable/dialpad_list_bg_sprd"
            android:fastScrollEnabled="true" />
        <ViewStub
            android:id="@+id/footer_stub"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout="@layout/footer_panel" />
        <LinearLayout
            android:id="@+id/maindial"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginTop="95dip"
            android:layout_alignParentBottom="true"
            android:background="@android:color/transparent"
            android:orientation="vertical" >
            <View
                android:layout_width="match_parent"
                android:layout_height="1dip"
                android:background="@android:color/transparent" />
            <!-- 按键部分 -->
            <include layout="@layout/dialpad_new_ui" />

            <!-- 拨号按钮 -->
            <include layout="@layout/dialpad_additional_buttons_dial_new_ui" />
        </LinearLayout>
    </FrameLayout>
    <ListView
        android:id="@+id/dialpadChooser"
        android:layout_width="match_parent"
        android:background="@drawable/dialpad_list_bg_sprd" 
        android:layout_height="1dip"
        android:layout_weight="1" />
</LinearLayout>

 

account_filter_header.xml

[html] view plain copy print ?
  1. <LinearLayout  
  2.     xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:id="@+id/account_filter_header_container"  
  4.     android:layout_width="match_parent"  
  5.     android:layout_height="wrap_content"  
  6.     android:orientation="vertical"  
  7.     android:paddingTop="@dimen/list_header_extra_top_padding"  
  8.     android:layout_marginLeft="@dimen/contact_browser_list_header_left_margin"  
  9.     android:layout_marginRight="@dimen/contact_browser_list_header_right_margin"  
  10.     android:background="?android:attr/selectableItemBackground"  
  11.     android:visibility="gone">  
  12.     <TextView  
  13.         android:id="@+id/account_filter_header"  
  14.         style="@style/ContactListSeparatorTextViewStyle"  
  15.         android:paddingLeft="@dimen/contact_browser_list_item_text_indent" />  
  16. </LinearLayout>  
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/account_filter_header_container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:paddingTop="@dimen/list_header_extra_top_padding"
    android:layout_marginLeft="@dimen/contact_browser_list_header_left_margin"
    android:layout_marginRight="@dimen/contact_browser_list_header_right_margin"
    android:background="?android:attr/selectableItemBackground"
    android:visibility="gone">
    <TextView
        android:id="@+id/account_filter_header"
        style="@style/ContactListSeparatorTextViewStyle"
        android:paddingLeft="@dimen/contact_browser_list_item_text_indent" />
</LinearLayout>


dialpad_add_contacts_newui.xml

[html] view plain copy print ?
  1. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  2.     android:id="@+id/dialpadAddContactsButton"  
  3.     android:layout_width="match_parent"  
  4.     android:layout_height="match_parent"  
  5.     android:layout_gravity="center_horizontal"  
  6.     android:background="@drawable/dialpad_list_bg_sprd"  
  7.     android:orientation="horizontal" >  
  8.     <RelativeLayout   
  9.         android:layout_width="match_parent"  
  10.         android:layout_height="wrap_content"  
  11.         android:id="@+id/addContactLayout"  
  12.         android:clickable="true"  
  13.         android:background="@drawable/call_add_contact_button_pressed_new_ui"  
  14.         android:layout_gravity="center"  
  15.         android:gravity="center">  
  16.         <TextView  
  17.             android:layout_gravity="center"  
  18.             android:gravity="center"  
  19.             android:clickable="false"  
  20.             android:layout_width="wrap_content"  
  21.             android:layout_height="wrap_content"  
  22.             android:drawableLeft="@drawable/call_addcontract_icon_sprd"  
  23.             android:text="@string/create_new_contact"  
  24.             android:textSize="20sp" />  
  25.     </RelativeLayout>  
  26. </RelativeLayout>  
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/dialpadAddContactsButton"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center_horizontal"
    android:background="@drawable/dialpad_list_bg_sprd"
    android:orientation="horizontal" >
    <RelativeLayout 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/addContactLayout"
        android:clickable="true"
        android:background="@drawable/call_add_contact_button_pressed_new_ui"
        android:layout_gravity="center"
        android:gravity="center">
		<TextView
			android:layout_gravity="center"
			android:gravity="center"
			android:clickable="false"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:drawableLeft="@drawable/call_addcontract_icon_sprd"
			android:text="@string/create_new_contact"
			android:textSize="20sp" />
    </RelativeLayout>
</RelativeLayout>


dialpad.xml 拨号盘

Android phone 拨号UI_第3张图片

[html] view plain copy print ?
  1. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  2.     android:id="@+id/dialpad_container"  
  3.     android:layout_width="match_parent"  
  4.     android:layout_height="295dip"  
  5.     android:background="@android:color/transparent"  
  6.     android:orientation="vertical" >  
  7.     <View  
  8.         android:layout_width="fill_parent"  
  9.         android:layout_height="fill_parent"  
  10.         android:layout_alignParentTop="true"  
  11.         android:layout_marginBottom="465dip"  
  12.         android:background="@android:color/transparent"  
  13.         android:clickable="false"  
  14.         android:focusable="false" />  
  15.     <SlidingDrawer  
  16.         android:id="@+id/dialer_container"  
  17.         android:layout_width="match_parent"  
  18.         android:layout_height="match_parent"  
  19.         android:layout_alignParentBottom="true"  
  20.         android:layout_gravity="center_horizontal"  
  21.         android:background="@android:color/transparent"  
  22.         android:content="@+id/dialpad"  
  23.         android:handle="@+id/handle" >  
  24.         <View  
  25.             android:id="@id/handle"  
  26.             android:layout_width="fill_parent"  
  27.             android:layout_height="0px"  
  28.             android:background="@android:color/transparent"  
  29.             android:clickable="false"  
  30.             android:focusable="false" />  
  31.         <LinearLayout  
  32.             android:id="@id/dialpad"  
  33.             android:layout_width="match_parent"  
  34.             android:layout_height="match_parent"  
  35.             android:background="@drawable/call_number_bg_sprd"  
  36.             android:orientation="vertical" >       
  37.             <LinearLayout  
  38.                 android:id="@+id/digits_bkg"  
  39.                 android:layout_width="match_parent"  
  40.                 android:layout_height="72dip"  
  41.                 android:background="@android:color/transparent"  
  42.                 android:gravity="center" >  
  43.                 <LinearLayout  
  44.                     android:id="@+id/digits_container"  
  45.                     android:layout_width="match_parent"  
  46.                     android:layout_height="72dip"  
  47.                     android:background="@android:color/transparent"  
  48.                     android:layout_weight="@integer/dialpad_layout_weight_digits"  
  49.                     android:gravity="center" >  
  50.                     <com.android.contacts.dialpad.DigitsEditText  
  51.                         android:id="@+id/digits"  
  52.                         android:layout_width="0px"  
  53.                         android:layout_height="72dip"  
  54.                         android:layout_marginLeft="10dip"  
  55.                         android:layout_weight="1"  
  56.                         android:layout_marginTop="10dip"  
  57.                         android:background="@android:color/transparent"  
  58.                         android:gravity="center"  
  59.                         android:maxLength="@integer/dialpad_max_number_length"  
  60.                         android:nextFocusRight="@+id/overflow_menu"  
  61.                         android:textAppearance="@style/DialtactsDigitsTextAppearance_new_ui"  
  62.                         android:textColor="@android:color/black" />  
  63.                     <ImageButton  
  64.                         android:id="@+id/deleteButton"  
  65.                         android:layout_width="50dip"  
  66.                         android:layout_height="72dip"  
  67.                         android:layout_marginLeft="5dip"  
  68.                         android:layout_marginTop="3dip"                  
  69.                         android:layout_marginBottom="-7dip"  
  70.                         android:layout_marginRight="10dip"  
  71.                         android:background="@android:color/transparent"  
  72.                         android:focusable="false"  
  73.                         android:src="@drawable/delete_button_pressed_new_ui"/>  
  74.                     <ImageButton  
  75.                         android:id="@+id/overflow_menu"  
  76.                         android:layout_width="54dip"  
  77.                         android:layout_height="match_parent"  
  78.                         android:layout_alignParentRight="true"  
  79.                         android:background="?android:attr/selectableItemBackground"  
  80.                         android:contentDescription="@*android:string/action_menu_overflow_description"  
  81.                         android:nextFocusLeft="@id/digits"  
  82.                         android:src="@drawable/ic_menu_overflow" />  
  83.                 </LinearLayout>  
  84.             </LinearLayout>  
  85.             <TableLayout  
  86.                 android:layout_width="match_parent"  
  87.                 android:layout_height="223dip"  
  88.                 android:layout_gravity="center_horizontal"  
  89.                 android:layout_marginTop="@dimen/dialpad_vertical_margin"  
  90.                 android:background="@android:color/transparent"  
  91.                 android:layout_marginRight="4dip"  
  92.                 android:layout_marginLeft="4dip" >  
  93.                 <TableRow  
  94.                     android:layout_height="54dip"  
  95.                     android:layout_marginBottom="2dip"  
  96.                     android:layout_weight="1" >  
  97.                     <ImageButton  
  98.                         android:id="@+id/one"  
  99.                         style="@style/DialtactsDialpadButtonStyleNewUI"  
  100.                         android:contentDescription="@string/description_image_button_one"  
  101.                         android:background="@drawable/dial_num_pressed_new_ui"  
  102.                         android:layout_marginRight="2dip"  
  103.                         android:src="@drawable/dial_num_1_wht" />               
  104.                     <ImageButton  
  105.                         android:id="@+id/two"  
  106.                         style="@style/DialtactsDialpadButtonStyleNewUI"  
  107.                         android:contentDescription="@string/description_image_button_two"  
  108.                         android:background="@drawable/dial_num_pressed_new_ui"  
  109.                         android:layout_marginRight="2dip"  
  110.                         android:src="@drawable/dial_num_2_wht" />  
  111.                     <ImageButton  
  112.                         android:id="@+id/three"  
  113.                         style="@style/DialtactsDialpadButtonStyleNewUI"  
  114.                         android:contentDescription="@string/description_image_button_three"  
  115.                        android:background="@drawable/dial_num_pressed_new_ui"  
  116.                         android:src="@drawable/dial_num_3_wht" />  
  117.                 </TableRow>  
  118.                 <TableRow  
  119.                     android:layout_height="54dip"  
  120.                     android:layout_marginBottom="2dip"  
  121.                     android:layout_weight="1" >  
  122.                     <ImageButton  
  123.                         android:id="@+id/four"  
  124.                         style="@style/DialtactsDialpadButtonStyleNewUI"  
  125.                         android:contentDescription="@string/description_image_button_four"  
  126.                         android:background="@drawable/dial_num_pressed_new_ui"  
  127.                         android:layout_marginRight="2dip"  
  128.                         android:src="@drawable/dial_num_4_wht" />  
  129.                     <ImageButton  
  130.                         android:id="@+id/five"  
  131.                         style="@style/DialtactsDialpadButtonStyleNewUI"  
  132.                         android:background="@drawable/dial_num_pressed_new_ui"  
  133.                         android:contentDescription="@string/description_image_button_five"  
  134.                         android:layout_marginRight="2dip"  
  135.                         android:src="@drawable/dial_num_5_wht" />  
  136.                     <ImageButton  
  137.                         android:id="@+id/six"  
  138.                         style="@style/DialtactsDialpadButtonStyleNewUI"  
  139.                         android:paddingLeft="4dip"  
  140.                         android:contentDescription="@string/description_image_button_six"  
  141.                         android:background="@drawable/dial_num_pressed_new_ui"  
  142.                         android:src="@drawable/dial_num_6_wht" />  
  143.                 </TableRow>  
  144.                 <TableRow  
  145.                     android:layout_height="54dip"  
  146.                     android:layout_marginBottom="2dip"  
  147.                     android:layout_weight="1" >  
  148.                     <ImageButton  
  149.                         android:id="@+id/seven"  
  150.                         style="@style/DialtactsDialpadButtonStyleNewUI"  
  151.                         android:background="@drawable/dial_num_pressed_new_ui"  
  152.                         android:contentDescription="@string/description_image_button_seven"  
  153.                         android:layout_marginRight="2dip"  
  154.                         android:src="@drawable/dial_num_7_wht" />  
  155.                     <ImageButton  
  156.                         android:id="@+id/eight"  
  157.                         style="@style/DialtactsDialpadButtonStyleNewUI"  
  158.                         android:background="@drawable/dial_num_pressed_new_ui"  
  159.                         android:contentDescription="@string/description_image_button_eight"  
  160.                         android:layout_marginRight="2dip"  
  161.                         android:src="@drawable/dial_num_8_wht" />  
  162.                     <ImageButton  
  163.                         android:id="@+id/nine"  
  164.                         style="@style/DialtactsDialpadButtonStyleNewUI"  
  165.                         android:background="@drawable/dial_num_pressed_new_ui"  
  166.                         android:contentDescription="@string/description_image_button_nine"  
  167.                         android:src="@drawable/dial_num_9_wht" />  
  168.                 </TableRow>  
  169.                 <TableRow  
  170.                     android:layout_height="54dip"  
  171.                     android:layout_marginBottom="1dip"  
  172.                     android:layout_weight="1" >  
  173.                    <ImageButton  
  174.                         android:id="@+id/star"  
  175.                         style="@style/DialtactsDialpadButtonStyleNewUI"  
  176.                         android:background="@drawable/dial_num_pressed_new_ui"  
  177.                         android:contentDescription="@string/description_image_button_star"  
  178.                         android:layout_marginRight="2dip"  
  179.                         android:src="@drawable/dial_num_star_wht" />  
  180.                     <ImageButton  
  181.                         android:id="@+id/zero"  
  182.                         style="@style/DialtactsDialpadButtonStyleNewUI"  
  183.                         android:background="@drawable/dial_num_pressed_new_ui"  
  184.                         android:contentDescription="@string/description_image_button_zero"  
  185.                         android:layout_marginRight="2dip"  
  186.                         android:src="@drawable/dial_num_0_wht"/>  
  187.                     <ImageButton  
  188.                         android:id="@+id/pound"  
  189.                         style="@style/DialtactsDialpadButtonStyleNewUI"  
  190.                         android:background="@drawable/dial_num_pressed_new_ui"  
  191.                         android:contentDescription="@string/description_image_button_pound"  
  192.                         android:src="@drawable/dial_num_pound_wht" />  
  193.                 </TableRow>  
  194.             </TableLayout>  
  195.         </LinearLayout>  
  196.     </SlidingDrawer>  
  197. </RelativeLayout>  
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/dialpad_container"
    android:layout_width="match_parent"
    android:layout_height="295dip"
    android:background="@android:color/transparent"
    android:orientation="vertical" >
    <View
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentTop="true"
        android:layout_marginBottom="465dip"
        android:background="@android:color/transparent"
        android:clickable="false"
        android:focusable="false" />
    <SlidingDrawer
        android:id="@+id/dialer_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true"
        android:layout_gravity="center_horizontal"
        android:background="@android:color/transparent"
        android:content="@+id/dialpad"
        android:handle="@+id/handle" >
        <View
            android:id="@id/handle"
            android:layout_width="fill_parent"
            android:layout_height="0px"
            android:background="@android:color/transparent"
            android:clickable="false"
            android:focusable="false" />
        <LinearLayout
            android:id="@id/dialpad"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/call_number_bg_sprd"
            android:orientation="vertical" >     
			<LinearLayout
				android:id="@+id/digits_bkg"
				android:layout_width="match_parent"
				android:layout_height="72dip"
				android:background="@android:color/transparent"
				android:gravity="center" >
				<LinearLayout
					android:id="@+id/digits_container"
					android:layout_width="match_parent"
					android:layout_height="72dip"
					android:background="@android:color/transparent"
					android:layout_weight="@integer/dialpad_layout_weight_digits"
					android:gravity="center" >
					<com.android.contacts.dialpad.DigitsEditText
						android:id="@+id/digits"
						android:layout_width="0px"
						android:layout_height="72dip"
						android:layout_marginLeft="10dip"
						android:layout_weight="1"
						android:layout_marginTop="10dip"
						android:background="@android:color/transparent"
						android:gravity="center"
						android:maxLength="@integer/dialpad_max_number_length"
						android:nextFocusRight="@+id/overflow_menu"
						android:textAppearance="@style/DialtactsDigitsTextAppearance_new_ui"
						android:textColor="@android:color/black" />
					<ImageButton
						android:id="@+id/deleteButton"
						android:layout_width="50dip"
						android:layout_height="72dip"
						android:layout_marginLeft="5dip"
						android:layout_marginTop="3dip"                
						android:layout_marginBottom="-7dip"
						android:layout_marginRight="10dip"
						android:background="@android:color/transparent"
						android:focusable="false"
						android:src="@drawable/delete_button_pressed_new_ui"/>
					<ImageButton
						android:id="@+id/overflow_menu"
						android:layout_width="54dip"
						android:layout_height="match_parent"
						android:layout_alignParentRight="true"
						android:background="?android:attr/selectableItemBackground"
						android:contentDescription="@*android:string/action_menu_overflow_description"
						android:nextFocusLeft="@id/digits"
						android:src="@drawable/ic_menu_overflow" />
				</LinearLayout>
			</LinearLayout>
            <TableLayout
                android:layout_width="match_parent"
                android:layout_height="223dip"
                android:layout_gravity="center_horizontal"
                android:layout_marginTop="@dimen/dialpad_vertical_margin"
                android:background="@android:color/transparent"
                android:layout_marginRight="4dip"
                android:layout_marginLeft="4dip" >
                <TableRow
                    android:layout_height="54dip"
                    android:layout_marginBottom="2dip"
                    android:layout_weight="1" >
                    <ImageButton
                        android:id="@+id/one"
                        style="@style/DialtactsDialpadButtonStyleNewUI"
                        android:contentDescription="@string/description_image_button_one"
                        android:background="@drawable/dial_num_pressed_new_ui"
                        android:layout_marginRight="2dip"
                        android:src="@drawable/dial_num_1_wht" />             
                    <ImageButton
                        android:id="@+id/two"
                        style="@style/DialtactsDialpadButtonStyleNewUI"
                        android:contentDescription="@string/description_image_button_two"
                        android:background="@drawable/dial_num_pressed_new_ui"
                        android:layout_marginRight="2dip"
                        android:src="@drawable/dial_num_2_wht" />
                    <ImageButton
                        android:id="@+id/three"
                        style="@style/DialtactsDialpadButtonStyleNewUI"
                        android:contentDescription="@string/description_image_button_three"
                       android:background="@drawable/dial_num_pressed_new_ui"
                        android:src="@drawable/dial_num_3_wht" />
                </TableRow>
                <TableRow
                    android:layout_height="54dip"
                    android:layout_marginBottom="2dip"
                    android:layout_weight="1" >
                    <ImageButton
                        android:id="@+id/four"
                        style="@style/DialtactsDialpadButtonStyleNewUI"
                        android:contentDescription="@string/description_image_button_four"
                        android:background="@drawable/dial_num_pressed_new_ui"
                        android:layout_marginRight="2dip"
                        android:src="@drawable/dial_num_4_wht" />
                    <ImageButton
                        android:id="@+id/five"
                        style="@style/DialtactsDialpadButtonStyleNewUI"
                        android:background="@drawable/dial_num_pressed_new_ui"
                        android:contentDescription="@string/description_image_button_five"
                        android:layout_marginRight="2dip"
                        android:src="@drawable/dial_num_5_wht" />
                    <ImageButton
                        android:id="@+id/six"
                        style="@style/DialtactsDialpadButtonStyleNewUI"
                        android:paddingLeft="4dip"
                        android:contentDescription="@string/description_image_button_six"
                        android:background="@drawable/dial_num_pressed_new_ui"
                        android:src="@drawable/dial_num_6_wht" />
                </TableRow>
                <TableRow
                    android:layout_height="54dip"
                    android:layout_marginBottom="2dip"
                    android:layout_weight="1" >
                    <ImageButton
                        android:id="@+id/seven"
                        style="@style/DialtactsDialpadButtonStyleNewUI"
                        android:background="@drawable/dial_num_pressed_new_ui"
                        android:contentDescription="@string/description_image_button_seven"
                        android:layout_marginRight="2dip"
                        android:src="@drawable/dial_num_7_wht" />
                    <ImageButton
                        android:id="@+id/eight"
                        style="@style/DialtactsDialpadButtonStyleNewUI"
                        android:background="@drawable/dial_num_pressed_new_ui"
                        android:contentDescription="@string/description_image_button_eight"
                        android:layout_marginRight="2dip"
                        android:src="@drawable/dial_num_8_wht" />
                    <ImageButton
                        android:id="@+id/nine"
                        style="@style/DialtactsDialpadButtonStyleNewUI"
                        android:background="@drawable/dial_num_pressed_new_ui"
                        android:contentDescription="@string/description_image_button_nine"
                        android:src="@drawable/dial_num_9_wht" />
                </TableRow>
                <TableRow
                    android:layout_height="54dip"
                    android:layout_marginBottom="1dip"
                    android:layout_weight="1" >
                   <ImageButton
                        android:id="@+id/star"
                        style="@style/DialtactsDialpadButtonStyleNewUI"
                        android:background="@drawable/dial_num_pressed_new_ui"
                        android:contentDescription="@string/description_image_button_star"
                        android:layout_marginRight="2dip"
                        android:src="@drawable/dial_num_star_wht" />
                    <ImageButton
                        android:id="@+id/zero"
                        style="@style/DialtactsDialpadButtonStyleNewUI"
                        android:background="@drawable/dial_num_pressed_new_ui"
                        android:contentDescription="@string/description_image_button_zero"
                        android:layout_marginRight="2dip"
                        android:src="@drawable/dial_num_0_wht"/>
                    <ImageButton
                        android:id="@+id/pound"
                        style="@style/DialtactsDialpadButtonStyleNewUI"
                        android:background="@drawable/dial_num_pressed_new_ui"
                        android:contentDescription="@string/description_image_button_pound"
                        android:src="@drawable/dial_num_pound_wht" />
                </TableRow>
            </TableLayout>
        </LinearLayout>
    </SlidingDrawer>
</RelativeLayout>


dialpad_additional_buttons_dial.xml

[html] view plain copy print ?
  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  2.     android:id="@+id/dialpadAdditionalButtons"  
  3.     android:layout_width="match_parent"  
  4.     android:layout_height="wrap_content"  
  5.     android:layout_alignParentBottom="false"  
  6.     android:layout_gravity="center_horizontal"  
  7.     android:background="@android:color/transparent"      
  8.     android:orientation="horizontal" >   
  9.     <LinearLayout  
  10.         android:layout_width="match_parent"  
  11.         android:layout_height="54dip"  
  12.         android:layout_alignParentBottom="true"  
  13.         android:background="@android:color/transparent"  
  14.         android:layout_marginTop="1dip"  
  15.         android:layout_marginBottom="4dip"  
  16.         android:layout_marginRight="4dip"  
  17.         android:layout_marginLeft="3dip"  
  18.         android:orientation="horizontal" >  
  19.         <ImageButton  
  20.             android:id="@+id/videoButton"  
  21.             android:layout_width="match_parent"  
  22.             android:layout_height="54dip"  
  23.             android:layout_gravity="center_vertical"  
  24.             android:layout_weight="1"  
  25.             android:layout_marginRight="3dip"  
  26.             android:contentDescription="@string/description_search_button"  
  27.             android:src="@drawable/vt_button_pressed_new_ui"  
  28.             android:background="@android:color/transparent"  
  29.             android:scaleType="fitXY"  
  30.             android:state_enabled="false" />  
  31.         <ImageButton  
  32.             android:id="@+id/dialButton"  
  33.             android:layout_width="match_parent"  
  34.             android:layout_height="54dip"  
  35.             android:layout_gravity="center_vertical"  
  36.             android:layout_weight="1"  
  37.             android:contentDescription="@string/description_dial_button"  
  38.             android:src="@drawable/call_button_pressed_new_ui"  
  39.             android:scaleType="fitXY"  
  40.             android:background="#00000000"  
  41.             android:state_enabled="false" />  
  42.         <ImageButton  
  43.             android:id="@+id/showview"  
  44.             android:state_enabled="true"  
  45.             android:layout_width="match_parent"  
  46.             android:layout_height="54dip"  
  47.             android:layout_gravity="center_vertical"  
  48.             android:layout_weight="1"  
  49.             android:contentDescription="@string/description_delete_button"  
  50.             android:layout_marginLeft="2dip"  
  51.             android:src="@drawable/keypad_down_sprd"  
  52.             android:scaleType="center"  
  53.             android:background="@drawable/keypad_button_background_pressed_new_ui" />  
  54.     </LinearLayout>  
  55. </LinearLayout>  

你可能感兴趣的:(Android phone 拨号UI)