仿微信聊天界面点击底部+图标弹出相应选项
2015-12-26 20:17
911 查看
本文想要实现的简单效果如下(gif效果不是很清晰,大家见谅。。):
以下是如何具体实现的相关部分代码:
main.xml:
继承自RelativeLayout的类AddRelativeLayout的实现:
项目完整源码点击这里下载。
以下是如何具体实现的相关部分代码:
main.xml:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#f3f7f8" > <LinearLayout android:id="@+id/ll_bottom" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginBottom="10dip" android:layout_alignParentBottom="true" > <!-- 聊天输入框 --> <include android:layout_width="fill_parent" android:layout_height="wrap_content" layout="@layout/other_relativelayout" /> </LinearLayout> <ListView android:id="@+id/listview" android:background="#fed234" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_below="@id/ll_bottom" android:cacheColorHint="#0000" android:divider="@null" android:dividerHeight="5dp" android:scrollbarStyle="outsideOverlay" android:stackFromBottom="true" /> </RelativeLayout>
继承自RelativeLayout的类AddRelativeLayout的实现:
public class AddRelativeLayout extends RelativeLayout implements OnClickListener{ private Context context; //显示布局 private View view; private EditText et_sendmess; private Button btnSend; private ImageButton ib_pic,ib_file,ib_audio,ib_video; public AddRelativeLayout(Context context) { super(context); this.context = context; } public AddRelativeLayout(Context context, AttributeSet attrs) { super(context, attrs); this.context = context; } public AddRelativeLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); this.context = context; } protected void onFinishInflate() { super.onFinishInflate(); initView(); } private void initView() { // TODO Auto-generated method stub ib_pic = (ImageButton) findViewById(R.id.ib1); ib_file = (ImageButton) findViewById(R.id.ib2); ib_audio = (ImageButton) findViewById(R.id.ib3); ib_video = (ImageButton) findViewById(R.id.ib4); et_sendmess = (EditText) findViewById(R.id.et_sendmessage); btnSend = (Button) findViewById(R.id.btn_send); findViewById(R.id.btn_other).setOnClickListener(this); view = findViewById(R.id.rl_other); ib_pic.setOnClickListener(new OnClickListener(){ @Override public void onClick(View arg0) { // TODO Auto-generated method stub et_sendmess.setText("picture..."); } }); } /** * 隐藏表情选择框 */ public boolean hideFaceView() { // 隐藏表情选择框 if (view.getVisibility() == View.VISIBLE) { view.setVisibility(View.GONE); return true; } return false; } @Override public void onClick(View v) { // TODO Auto-generated method stub switch(v.getId()){ case R.id.btn_other: // 隐藏表情选择框 if (view.getVisibility() == View.VISIBLE) view.setVisibility(View.GONE); else view.setVisibility(View.VISIBLE); break; case R.id.et_sendmessage: // 隐藏表情选择框 if (view.getVisibility() == View.VISIBLE) view.setVisibility(View.GONE); break; default : break; } } }
项目完整源码点击这里下载。
相关文章推荐
- Android调用微信登陆、分享、支付
- 每次调起微信JSAPI报错或支付失败
- 微信内网页某些安卓手机不能上传图片文件的问题(1)
- Cacti微信企业号图文报警
- 仿照微信朋友缩略图实现
- 微信公众号nodejs版
- 微信分享失败之checkArgs fail, thumbData is invalid
- 【java微信开发】环境搭建
- 微信公众平台接口API
- 微信浏览器里location.reload问题
- 微信iOS多设备多字体适配方案总结
- iOS微信小视频优化心得
- 微信支付
- ios 微信登录
- 微信分享JS接口失效说明及解决方案
- 自动保存微信的小视频
- java万年历小程序
- 微信发送消息中带网页连接
- 微信JS SDK Demo
- ViewDragHelper实现微信侧滑