继上一篇仿新浪微博底栏,我们在写个仿QQ空间底栏的效果。

先看主布局文件:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="fill_parent"android:layout_height="fill_parent" ><FrameLayoutandroid:id="@+id/frame_content"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_above="@+id/frameLayout1"android:layout_alignParentLeft="true"android:layout_alignParentRight="true"android:layout_alignParentTop="true"android:background="#ffffff" ></FrameLayout><FrameLayoutandroid:id="@+id/frameLayout1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentBottom="true"android:layout_alignParentLeft="true"android:background="@drawable/qz_bg_toolbar_new" ><LinearLayoutandroid:layout_width="fill_parent"android:layout_height="fill_parent"android:layout_marginTop="1dp"android:gravity="center_horizontal" ><FrameLayoutandroid:id="@+id/layout_friendfeed"android:layout_width="fill_parent"android:layout_height="48dp"android:layout_weight="1"android:background="@drawable/home_btn_bg"><ImageViewandroid:id="@+id/image_friendfeed"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="top|center"android:layout_marginTop="1.0dip"android:background="@drawable/tab_btn_friendfeed"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="bottom|center"android:layout_marginBottom="6.0dip"android:text="动态"android:textColor="#ffffff"android:textSize="10sp" /></FrameLayout><FrameLayoutandroid:id="@+id/layout_myfeed"android:layout_width="fill_parent"android:layout_height="48dp"android:layout_weight="1"android:background="@drawable/home_btn_bg"><ImageViewandroid:id="@+id/image_myfeed"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="top|center"android:layout_marginTop="1.0dip"android:background="@drawable/tab_btn_myfeed"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="bottom|center"android:layout_marginBottom="6.0dip"android:text="与我想关"android:textColor="#ffffff"android:textSize="10sp" /></FrameLayout><FrameLayoutandroid:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_weight="1" ></FrameLayout><FrameLayoutandroid:id="@+id/layout_home"android:layout_width="fill_parent"android:layout_height="48dp"android:layout_weight="1"android:background="@drawable/home_btn_bg"><ImageViewandroid:id="@+id/image_home"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="top|center"android:layout_marginTop="1.0dip"android:background="@drawable/tab_btn_home"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="bottom|center"android:layout_marginBottom="6.0dip"android:text="我的空间"android:textColor="#ffffff"android:textSize="10sp" /></FrameLayout><FrameLayoutandroid:id="@+id/layout_more"android:layout_width="fill_parent"android:layout_height="48dp"android:layout_weight="1" android:background="@drawable/home_btn_bg"><ImageViewandroid:id="@+id/image_more"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="top|center"android:layout_marginTop="1.0dip"android:background="@drawable/tab_btn_more"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="bottom|center"android:layout_marginBottom="6.0dip"android:text="更多"android:textColor="#ffffff"android:textSize="10sp" /></FrameLayout></LinearLayout></FrameLayout><ImageViewandroid:id="@+id/toggle_btn"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentBottom="true"android:layout_centerHorizontal="true"android:src="@drawable/qz_bg_toolbar_btn_normal" /><ImageViewandroid:id="@+id/plus_btn"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignTop="@+id/frameLayout1"android:layout_centerHorizontal="true"android:layout_marginTop="6dip"android:src="@drawable/qz_icon_toolbar_plus" /></RelativeLayout>

主MainActivity的代码:

package cn.cl.qzonedemo;import android.content.Context;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.PopupWindow.OnDismissListener;public class MainActivity extends FragmentActivity implements OnClickListener {private Main1Fragment page1;private Main2Fragment page2;private Main3Fragment page3;private Main4Fragment page4;private FrameLayout fl_friendfeed;private FrameLayout fl_myfeed;private FrameLayout fl_home;private FrameLayout fl_more;private ImageView iv_friendfeed;private ImageView iv_myfeed;private ImageView iv_home;private ImageView iv_more;private ImageView iv_toggle;private ImageView iv_plus;private PopupWindow popWindow;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);setupView();clickFriendFeedFl();}private void setupView() {fl_friendfeed = (FrameLayout) findViewById(R.id.layout_friendfeed);fl_myfeed = (FrameLayout) findViewById(R.id.layout_myfeed);fl_home = (FrameLayout) findViewById(R.id.layout_home);fl_more = (FrameLayout) findViewById(R.id.layout_more);iv_friendfeed = (ImageView) findViewById(R.id.image_friendfeed);iv_myfeed = (ImageView) findViewById(R.id.image_myfeed);iv_home = (ImageView) findViewById(R.id.image_home);iv_more = (ImageView) findViewById(R.id.image_more);fl_friendfeed.setOnClickListener(this);fl_myfeed.setOnClickListener(this);fl_home.setOnClickListener(this);fl_more.setOnClickListener(this);iv_toggle = (ImageView) findViewById(R.id.toggle_btn);iv_toggle.setOnClickListener(this);iv_plus = (ImageView) findViewById(R.id.plus_btn);}@Overridepublic void onClick(View v) {switch (v.getId()) {case R.id.layout_friendfeed:clickFriendFeedFl();break;case R.id.layout_myfeed:clickMyFeedFl();break;case R.id.layout_home:clickHomeFl();break;case R.id.layout_more:clickMoreFl();break;case R.id.toggle_btn:clickPlusBtn();break;default:break;}}private void clickFriendFeedFl() {page1 = new Main1Fragment();FragmentTransaction fragmentTransaction = this.getSupportFragmentManager().beginTransaction();fragmentTransaction.replace(R.id.frame_content, page1);fragmentTransaction.commit();fl_friendfeed.setSelected(true);iv_friendfeed.setSelected(true);fl_myfeed.setSelected(false);iv_myfeed.setSelected(false);fl_home.setSelected(false);iv_home.setSelected(false);fl_more.setSelected(false);iv_more.setSelected(false);}private void clickMyFeedFl() {page2 = new Main2Fragment();FragmentTransaction fragmentTransaction = this.getSupportFragmentManager().beginTransaction();fragmentTransaction.replace(R.id.frame_content, page2);fragmentTransaction.commit();fl_friendfeed.setSelected(false);iv_friendfeed.setSelected(false);fl_myfeed.setSelected(true);iv_myfeed.setSelected(true);fl_home.setSelected(false);iv_home.setSelected(false);fl_more.setSelected(false);iv_more.setSelected(false);}private void clickHomeFl() {page3 = new Main3Fragment();FragmentTransaction fragmentTransaction = this.getSupportFragmentManager().beginTransaction();fragmentTransaction.replace(R.id.frame_content, page3);fragmentTransaction.commit();fl_friendfeed.setSelected(false);iv_friendfeed.setSelected(false);fl_myfeed.setSelected(false);iv_myfeed.setSelected(false);fl_home.setSelected(true);iv_home.setSelected(true);fl_more.setSelected(false);iv_more.setSelected(false);}private void clickMoreFl() {page4 = new Main4Fragment();FragmentTransaction fragmentTransaction = this.getSupportFragmentManager().beginTransaction();fragmentTransaction.replace(R.id.frame_content, page4);fragmentTransaction.commit();fl_friendfeed.setSelected(false);iv_friendfeed.setSelected(false);fl_myfeed.setSelected(false);iv_myfeed.setSelected(false);fl_home.setSelected(false);iv_home.setSelected(false);fl_more.setSelected(true);iv_more.setSelected(true);}private void clickPlusBtn() {showPopupWindow(iv_toggle);iv_toggle.setImageResource(R.drawable.qz_bg_skin_toolbar_btn_pressed);iv_plus.setImageResource(R.drawable.qz_icon_toolbar_plusback);}private void restorePlusBtn() {iv_toggle.setImageResource(R.drawable.qz_bg_toolbar_btn_normal);iv_plus.setImageResource(R.drawable.qz_icon_toolbar_plus);}@SuppressWarnings("deprecation")private void showPopupWindow(View parent) {if (popWindow == null) {LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);View view = layoutInflater.inflate(R.layout.write_tab, null);popWindow = new PopupWindow(view,LinearLayout.LayoutParams.MATCH_PARENT, 320);}popWindow.setFocusable(true);popWindow.setOutsideTouchable(true);popWindow.setBackgroundDrawable(new BitmapDrawable());popWindow.showAsDropDown(parent, Gravity.CENTER, 0);popWindow.setOnDismissListener(new OnDismissListener() {              @Override  public void onDismiss() {  restorePlusBtn();               }  }); }}

至此为止,主要代码就写完了,具体的请看demo源码:

源码下载

Android仿QQ空间底栏相关推荐

  1. Android仿QQ空间底部菜单

    之前曾经在网上看到Android仿QQ空间底部菜单的Demo,发现这个Demo有很多Bug,布局用了很多神秘数字.于是研究了一下QQ空间底部菜单的实现,自己写了一个,供大家参考.效果如下图所示:  点 ...

  2. Android仿QQ空间二级评论列表

    之前项目中产品需求带二级的评论列表,首先想到是QQ空间评论列表. 先上效果图 下面我们来分析一下布局结构,首先一级列表是listview,然后二级列表也可以有多条,为了省事我只添加了一条,第一反应是l ...

  3. android仿qq动态,Android仿QQ空间主页面的实现

    今天模仿安卓QQ空间,效果如下: 打开程序的启动画面和导航页面我就不做了,大家可以模仿微信的那个做一下,很简单.这次主要做一下主页面的实现,下面是主页面的布局: android:layout_widt ...

  4. android写qq动态界面,Android_Android仿QQ空间主页面的实现,今天模仿安卓QQ空间,效果如 - phpStudy...

    Android仿QQ空间主页面的实现 今天模仿安卓QQ空间,效果如下: 打开程序的启动画面和导航页面我就不做了,大家可以模仿微信的那个做一下,很简单.这次主要做一下主页面的实现,下面是主页面的布局: ...

  5. 【Android UI设计与开发】第09期:底部菜单栏(四)Fragment+PopupWindow仿QQ空间最新版底部菜单栏

    转载请注明出处:http://blog.csdn.net/yangyu20121224/article/details/9023451          在今天的这篇文章当中,我依然会以实战加理论结合 ...

  6. android弹窗使用总结,高仿QQ空间操作弹窗

    android弹窗一共有两种方式,一种是dialog及其子类,另一种是popupwindow:Dialog及其子类尤其AlertDialog是最常用的,也是最自由的一种. **Popupwindow与 ...

  7. java 仿qq空间_仿QQ空间和微信朋友圈,高解耦高复用高灵活

    先看看效果: 用极少的代码实现了 动态详情 及 二级评论 的 数据获取与处理 和 UI显示与交互,并且高解耦.高复用.高灵活. 动态列表界面MomentListFragment支持 下拉刷新与上拉加载 ...

  8. 仿QQ空间图片放缩查看

    仿QQ空间图片放缩查看 仿QQ空间图片放缩查看,点击图片从原位置放大到全屏,后退从全屏缩小到原位置,效果非常好. 下载地址:http://www.devstore.cn/code/info/830.h ...

  9. 高仿QQ空间项目实战开发(带服务器端程序)

    大家好,今天我在这里分享一个小程序.高仿QQ空间的APP,这里给大家分享一个安卓APP和PHP写的服务器程序.想提高安卓开发能力或安卓和后台服务器一起做的初学者值得一看,老鸟跳过. 接下来我们看看效果 ...

最新文章

  1. CSRF verification failed. Request aborted. 表单提交方法为POST时的报错
  2. 值得推荐的C/C++框架和库(转载)
  3. 查找python矩阵中最大元素_找出矩阵中最大的元素
  4. 虹软人脸识别在 linux中so文件加载不到的问题
  5. [转]sql server性能分析--检测数据库阻塞语句
  6. eclipse php链接mysql_eclipse怎么连接mysql
  7. C++ - 命名空间,argc和argv详解,游戏人生介绍
  8. 状态机finite-state machine学习笔记2——按键消抖初步(1)
  9. java sjis_java乱码分析
  10. ocx注册成功但是页面不显示
  11. sip信令超时时间调整
  12. 2021-04-27
  13. 【C/C++】__stdcall、__cdcel和__fastcall定义与区别
  14. 《大慈恩寺三藏法师传》简介
  15. 微软账号登录后本地账号就关联了且没有改用本地账号登录如何解决?
  16. 微信小程序解密用户信息--java解密
  17. vue组件库大全(忘了的时候可以进来找一下~)
  18. NOI2017银色记
  19. ACL 2020 MART: Memory-Augmented Recurrent Transformer for Coherent Video Paragraph Captioning
  20. ubuntu10.10下更新无线网卡驱动

热门文章

  1. 如何使用唯物主义辩证法
  2. C语言中fscanf的作用,C语言中fgets和fscanf区别详解
  3. PHPCMS2008模板教程 默认模板解析及模板制作教程
  4. 全球与中国儿童双筒望远镜市场深度研究分析报告
  5. python和c++情侣网名_打通Python和C++之后?你懂的!
  6. ModbusTcp和ModbusRtu
  7. 编译原理【2】词法分析
  8. 【一】数据挖掘(DM)到底是何方神圣?
  9. php new 报错,php 安装imap报错“configure: error: utf8_mime2text() has new signature”解决
  10. 网站页面静态化(二)thymeleaf生成