首先看看模仿的像不像:
再來一發:
實現過程:
依賴類庫:actionbarsherlock
用actionbarsherlock來實現頂部的搜索的效果。
tab用的是Viewpaper實現的。
具體細節:
1.聊天、發現和通訊錄地下的綠色的矩形和地下的灰色細線是重合的,怎麼實現這種效果呢,只要使用
RelativeLayout,然後使得兩個ImageView的
android:layout_alignBottom屬性都指向同一個View。
2.“聊天”右邊的紅底白字1
要實現這個效果,可以通過重繪控件得到。
該項目的cmm.ui.view.tabTextview就是這樣一個控件,在OnDraw裏面
drawCircle和drawText等。
3.添加按鈕後出現的下拉菜單
這個效果用的PopupWindow做的。
// 加載數據
groups = new ArrayList<String>();
groups.add("發起羣聊");
groups.add("添加朋友");
groups.add("視頻聊天");
groups.add("掃一掃");
groups.add("拍照分享");
//加載左側對應圖標
mbitmaplist = new ArrayList<Bitmap>();
mbitmaplist.add(((BitmapDrawable)getResources().getDrawable(R.drawable.ofm_group_chat_icon)).getBitmap());
mbitmaplist.add(((BitmapDrawable)getResources().getDrawable(R.drawable.ofm_add_icon)).getBitmap());
mbitmaplist.add(((BitmapDrawable)getResources().getDrawable(R.drawable.ofm_video_icon)).getBitmap());
mbitmaplist.add(((BitmapDrawable)getResources().getDrawable(R.drawable.ofm_qrcode_icon)).getBitmap());
mbitmaplist.add(((BitmapDrawable)getResources().getDrawable(R.drawable.actionbar_camera_icon)).getBitmap());
GroupAdapter groupAdapter = new GroupAdapter(this, groups, mbitmaplist);
lv_group.setAdapter(groupAdapter);
// 創建一個PopuWidow對象
popupWindow = new PopupWindow(view, 400, LayoutParams.WRAP_CONTENT, true);
Popupwindow出現在偏右側,可以這樣做:
int xPos = (int)((windowManager.getDefaultDisplay().getWidth() - popupWindow.getWidth()) * (0.9));
Log.e("coder", "xPos:" + xPos);
popupWindow.showAsDropDown(parent, xPos, 0);
其他沒什麼,做的很簡陋,不喜請勿噴。
下載鏈接是:http://download.csdn.net/detail/u012463359/7411731