[模仿Android微信]之主界面

首先看看模仿的像不像:


再来一发:



实现过程:

依赖类库: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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章