- 浏览: 342436 次
文章分类
- 全部博客 (401)
- hibernate 入门 (24)
- it生活 (3)
- MapReduce 算法设计 (1)
- Android (13)
- java (6)
- web (4)
- 技术文章 (9)
- javascript (1)
- html5 (1)
- 数据库 (3)
- jquary (1)
- 1.网站首页原创Java技术区(对首页文章的要求: 原创、高质量、经过认真思考并精心写作。BlogJava管理团队会对首页的文章进行管理。) (0)
- 2.Java新手区 (0)
- 4.其他技术区 (0)
- 6.转载区(Java技术文章转载, 请注明原文出处) (0)
- 5.提问区(Java方面的技术提问) (0)
- servlet (1)
- IT 生活 (2)
- Struts2 (2)
- Struts 2 教程 (2)
- jQuery (1)
- DOM (1)
- ibatis,hibernate (1)
- 数据分析师 (1)
最新评论
-
NIIT_zhu:
我现在要做一个 基于exchange 2010的webmail ...
Exchange 2003 升级到Exchange 2010 之申请证书并分配服务! -
yinren13:
实在不行试试简单易用的turbomeeting,连接速度很快的 ...
QQ远程协助没动静?QQ版本有讲究 -
jicu7766240:
写得很好。赞一个!2年开发的我深有感触。这些我觉得说得很对。要 ...
老程序员的忠告:不要做浮躁的软件工程师 -
haohao-xuexi02:
好像很多人都买起却看不起书。。找各种理由不看。。我的书也这样 ...
老程序员的忠告:不要做浮躁的软件工程师 -
Judy123456:
希望可以提供源代码噢,我最近正好在学这个底部菜单,非常希望楼 ...
Android仿微信底部菜单
今天终于把公司的界面原型做完了,哈哈,提前完成正好趁现在有时间更新下最近学到的一些特殊效果。其中这个仿微信的底部菜单,真的要感谢家辉兄弟,我才得以解决。首先看一下实现后效果。
就下面的那个底部栏,下面看一下实现代码吧!
首先是布局main.xml:
[html] view plaincopy
- <?xml version="1.0" encoding="UTF-8"?>
- <TabHost android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent"
- xmlns:android="http://schemas.android.com/apk/res/android">
- <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent">
- <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="0.0dip" android:layout_weight="1.0" />
- <TabWidget android:id="@android:id/tabs" android:visibility="gone" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="0.0" />
- <LinearLayout android:gravity="bottom" android:layout_gravity="bottom" android:orientation="horizontal" android:id="@+id/main_tab_group" android:background="@drawable/bottom1" android:paddingTop="2.0dip" android:layout_width="fill_parent" android:layout_height="wrap_content">
- <FrameLayout android:background="@null" android:layout_width="0.0dip" android:layout_height="fill_parent" android:layout_weight="1.0">
- <LinearLayout android:id="@+id/main_layout_addExam" android:gravity="bottom|center" android:layout_width="fill_parent" android:layout_height="fill_parent">
- <RadioButton android:id="@+id/main_tab_addExam" android:checked="true" android:text="添加考试" android:drawableTop="@drawable/label_1" style="@style/MMTabButton" />
- </LinearLayout>
- <LinearLayout android:gravity="top|right|center" android:paddingRight="10.0dip" android:layout_width="fill_parent" android:layout_height="fill_parent">
- <TextView android:textSize="10.0dip" android:text="1" android:textColor="#ffffff" android:gravity="center" android:id="@+id/main_tab_unread_tv" android:background="@drawable/new_icon_2" android:visibility="invisible" android:layout_width="wrap_content" android:layout_height="wrap_content" />
- </LinearLayout>
- </FrameLayout>
- <FrameLayout android:background="@null" android:layout_width="0.0dip" android:layout_height="fill_parent" android:layout_weight="1.0">
- <LinearLayout android:id="@+id/main_layout_myExam" android:gravity="bottom|center" android:layout_width="fill_parent" android:layout_height="fill_parent">
- <RadioButton android:id="@+id/main_tab_myExam" android:text="我的考试" android:drawableTop="@drawable/label_2" style="@style/MMTabButton" />
- </LinearLayout>
- <LinearLayout android:gravity="top|right|center" android:paddingRight="10.0dip" android:layout_width="fill_parent" android:layout_height="fill_parent">
- <TextView android:textSize="10.0dip" android:textColor="#ffffff" android:gravity="center" android:id="@+id/main_tab_address" android:background="@drawable/new_icon_2" android:visibility="invisible" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="1" />
- </LinearLayout>
- </FrameLayout>
- <FrameLayout android:background="@null" android:layout_width="0.0dip" android:layout_height="fill_parent" android:layout_weight="1.0">
- <LinearLayout android:id="@+id/main_layout_message" android:gravity="bottom|center" android:layout_width="fill_parent" android:layout_height="fill_parent">
- <RadioButton android:id="@+id/main_tab_message" android:text="考试资讯" android:drawableTop="@drawable/label_3" style="@style/MMTabButton" />
- </LinearLayout>
- <LinearLayout android:gravity="top|right|center" android:paddingRight="10.0dip" android:layout_width="fill_parent" android:layout_height="fill_parent">
- <TextView android:textSize="12.0dip" android:textColor="#ffffff" android:gravity="center" android:id="@+id/main_tab_new_tv" android:background="@drawable/new_icon_2" android:visibility="visible" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="1" />
- </LinearLayout>
- </FrameLayout>
- <FrameLayout android:background="@null" android:layout_width="0.0dip" android:layout_height="fill_parent" android:layout_weight="1.0">
- <LinearLayout android:id="@+id/main_layout_settings" android:gravity="bottom|center" android:layout_width="fill_parent" android:layout_height="fill_parent">
- <RadioButton android:id="@+id/main_tab_settings" android:text="设置" android:drawableTop="@drawable/label4" style="@style/MMTabButton" />
- </LinearLayout>
- <LinearLayout android:gravity="top|right|center" android:paddingRight="10.0dip" android:layout_width="fill_parent" android:layout_height="fill_parent">
- <TextView android:textSize="10.0dip" android:textColor="#ffffff" android:gravity="center" android:id="@+id/main_tab_setting_new_tv" android:background="@drawable/new_icon_2" android:paddingLeft="6.0dip" android:paddingRight="6.0dip" android:visibility="invisible" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="1" />
- </LinearLayout>
- </FrameLayout>
- </LinearLayout>
- </LinearLayout>
- </TabHost>
其实就是用FrameLayout,微信也是这样布局的我反编译过。这样就可以灵活的布局那个红色的图标了。
下面看一下activity切换代码:
[html] view plaincopy
- import android.app.TabActivity;
- import android.content.Intent;
- import android.os.Bundle;
- import android.view.View;
- import android.view.View.OnClickListener;
- import android.view.Window;
- import android.widget.LinearLayout;
- import android.widget.RadioButton;
- import android.widget.TabHost;
- import android.widget.TextView;
- public class MainTabActivity extends TabActivity {
- TabHost tabHost;
- private TextView main_tab_unread_tv;
- private RadioButton main_tab_addExam, main_tab_myExam,main_tab_message,main_tab_settings;
- private LinearLayout main_layout_addExam,main_layout_myExam,main_layout_message,main_layout_settings;
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- this.requestWindowFeature(Window.FEATURE_NO_TITLE);
- setContentView(R.layout.main);
- initTab();
- init();
- }
- private void init() {
- main_tab_addExam = (RadioButton) findViewById(R.id.main_tab_addExam);
- main_tab_myExam = (RadioButton) findViewById(R.id.main_tab_myExam);
- main_tab_message=(RadioButton) findViewById(R.id.main_tab_message);
- main_tab_settings=(RadioButton) findViewById(R.id.main_tab_settings);
- main_layout_addExam=(LinearLayout) findViewById(R.id.main_layout_addExam);
- main_layout_myExam=(LinearLayout) findViewById(R.id.main_layout_myExam);
- main_layout_message=(LinearLayout) findViewById(R.id.main_layout_message);
- main_layout_settings=(LinearLayout) findViewById(R.id.main_layout_settings);
- main_tab_addExam.setCompoundDrawablesWithIntrinsicBounds(null, getResources().getDrawable(R.drawable.label_one_one), null, null);
- main_layout_addExam.setBackgroundResource(R.drawable.labelbg);
- main_tab_unread_tv=(TextView) findViewById(R.id.main_tab_unread_tv);
- //main_tab_unread_tv.setVisibility(View.VISIBLE);
- //main_tab_unread_tv.setText("3");
- main_tab_addExam.setOnClickListener(new OnClickListener() {
- public void onClick(View arg0) {
- tabHost.setCurrentTabByTag("first");
- /*main_tab_addExam.setBackgroundResource(R.drawable.label_one_one);
- main_tab_myExam.setBackgroundResource(R.drawable.label_2);
- main_tab_message.setBackgroundResource(R.drawable.label_3);*/
- //main_tab_addExam.setCompoundDrawables(null, getResources().getDrawable(R.drawable.label_one_one), null, null);
- main_tab_addExam.setCompoundDrawablesWithIntrinsicBounds(null, getResources().getDrawable(R.drawable.label_one_one), null, null);
- main_tab_myExam.setCompoundDrawablesWithIntrinsicBounds(null, getResources().getDrawable(R.drawable.label_2), null, null);
- main_tab_message.setCompoundDrawablesWithIntrinsicBounds(null, getResources().getDrawable(R.drawable.label_3), null, null);
- main_tab_settings.setCompoundDrawablesWithIntrinsicBounds(null, getResources().getDrawable(R.drawable.label4), null, null);
- main_layout_addExam.setBackgroundResource(R.drawable.labelbg);
- main_layout_myExam.setBackgroundResource(R.drawable.mm_trans);
- main_layout_message.setBackgroundResource(R.drawable.mm_trans);
- main_layout_settings.setBackgroundResource(R.drawable.mm_trans);
- }
- });
- main_tab_myExam.setOnClickListener(new OnClickListener() {
- public void onClick(View arg0) {
- tabHost.setCurrentTabByTag("second");
- /*main_tab_addExam.setBackgroundResource(R.drawable.label_1);
- main_tab_myExam.setBackgroundResource(R.drawable.label_two_one);
- main_tab_message.setBackgroundResource(R.drawable.label_3);*/
- main_tab_addExam.setCompoundDrawablesWithIntrinsicBounds(null, getResources().getDrawable(R.drawable.label_1), null, null);
- main_tab_myExam.setCompoundDrawablesWithIntrinsicBounds(null, getResources().getDrawable(R.drawable.label_two_one), null, null);
- main_tab_message.setCompoundDrawablesWithIntrinsicBounds(null, getResources().getDrawable(R.drawable.label_3), null, null);
- main_tab_settings.setCompoundDrawablesWithIntrinsicBounds(null, getResources().getDrawable(R.drawable.label4), null, null);
- main_layout_addExam.setBackgroundResource(R.drawable.mm_trans);
- main_layout_myExam.setBackgroundResource(R.drawable.labelbg);
- main_layout_message.setBackgroundResource(R.drawable.mm_trans);
- main_layout_settings.setBackgroundResource(R.drawable.mm_trans);
- }
- });
- main_tab_message.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- // TODO Auto-generated method stub
- tabHost.setCurrentTabByTag("third");
- /*main_tab_addExam.setBackgroundResource(R.drawable.label_1);
- main_tab_myExam.setBackgroundResource(R.drawable.label_2);
- main_tab_message.setBackgroundResource(R.drawable.label_three_one);*/
- main_tab_addExam.setCompoundDrawablesWithIntrinsicBounds(null, getResources().getDrawable(R.drawable.label_1), null, null);
- main_tab_myExam.setCompoundDrawablesWithIntrinsicBounds(null, getResources().getDrawable(R.drawable.label_2), null, null);
- main_tab_message.setCompoundDrawablesWithIntrinsicBounds(null, getResources().getDrawable(R.drawable.label_three_one), null, null);
- main_tab_settings.setCompoundDrawablesWithIntrinsicBounds(null, getResources().getDrawable(R.drawable.label4), null, null);
- main_layout_addExam.setBackgroundResource(R.drawable.mm_trans);
- main_layout_myExam.setBackgroundResource(R.drawable.mm_trans);
- main_layout_message.setBackgroundResource(R.drawable.labelbg);
- main_layout_settings.setBackgroundResource(R.drawable.mm_trans);
- }
- });
- main_tab_settings.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- // TODO Auto-generated method stub
- tabHost.setCurrentTabByTag("four");
- main_tab_addExam.setCompoundDrawablesWithIntrinsicBounds(null, getResources().getDrawable(R.drawable.label_1), null, null);
- main_tab_myExam.setCompoundDrawablesWithIntrinsicBounds(null, getResources().getDrawable(R.drawable.label_2), null, null);
- main_tab_message.setCompoundDrawablesWithIntrinsicBounds(null, getResources().getDrawable(R.drawable.label_3), null, null);
- main_tab_settings.setCompoundDrawablesWithIntrinsicBounds(null, getResources().getDrawable(R.drawable.label_four_one), null, null);
- main_layout_addExam.setBackgroundResource(R.drawable.mm_trans);
- main_layout_myExam.setBackgroundResource(R.drawable.mm_trans);
- main_layout_message.setBackgroundResource(R.drawable.mm_trans);
- main_layout_settings.setBackgroundResource(R.drawable.labelbg);
- }
- });
- }
- private void initTab(){
- tabHost=getTabHost();
- tabHost.addTab(tabHost.newTabSpec("first").setIndicator("first").setContent(
- new Intent(this, AddExamActivity.class)));
- tabHost.addTab(tabHost.newTabSpec("second").setIndicator("second").setContent(
- new Intent(this, MyExamActivity.class)));
- tabHost.addTab(tabHost.newTabSpec("third").setIndicator("third").setContent(
- new Intent(this, MessageActivity.class)));
- tabHost.addTab(tabHost.newTabSpec("four").setIndicator("four").setContent(
- new Intent(this, SettingActivity.class)));
- }
- }
评论
3 楼
Judy123456
2012-07-23
希望可以提供源代码噢,我最近正好在学这个底部菜单,非常希望楼主可以为我提供源代码,谢谢啦!希望能有完整的代码还有图片,非常感谢,我的邮箱的907365056@qq.com
2 楼
sogura
2012-07-06
LZ 可否提供源码学习啊?
1 楼
xmllong
2012-05-21
非常不错,能把你用到的图片资源发上来吗?非常想学习
发表评论
-
android44个常用的权限三
2012-04-20 20:15 101921、android.permission.CHANGE_NE ... -
android44个常用的权限二
2012-04-20 20:13 83211、android.permission.BLUETOO ... -
android44个常用的权限一
2012-04-20 20:03 7631、android.permission.ACCESS_CHE ... -
Android 操作权限大全 (android.permission)
2012-04-20 20:01 1142Android 操作权限大全 (android.perm ... -
android 界面布局 很好的一篇总结
2012-04-19 16:20 1384布局: 在 android 中我们常用的布局方 ... -
Android截取字符串
2012-04-19 16:16 2841String str = "a=111,b=222, ... -
Android开发教程之--sql语句
2012-04-18 18:26 920一、创建/删除表 String sql="C ... -
Android 提高显示布局文件的性能[Lesson 2 - 使用include标签重用Layout]
2012-04-17 23:36 1318Re-using Layouts with <in ... -
Android 提高显示布局文件的性能[Lesson 1 - 优化布局层级]
2012-04-17 23:35 1499Optimizing Layout Hierarchie ... -
Android适配不同的屏幕[Lesson 3 - 实现可适配的UI流程]
2012-04-17 23:34 1314Implementing Adaptative UI F ... -
Android 适配不同的屏幕[Lesson 2 - 适配不同屏幕密度]
2012-04-17 23:33 1383Supporting Different Densiti ... -
【Android Training - 01】适配不同的屏幕[Lesson 1-支持不同的屏幕大小]
2012-04-17 23:32 1190Dependencies and prerequisit ...
相关推荐
Android仿微信底部菜单栏+顶部菜单栏,效果看博文http://blog.csdn.net/evankaka/article/details/44121457
Android 仿微信底部菜单渐变
高仿微信底部菜单栏,无bug!导入即可使用!承让^_
android 高仿微信底部菜单 用自定义的radiobutton和radiogroup实现,能实现气泡数字的效果,viewpager+自定义的radiobutton+radiogroup
Android 仿微信底部菜单栏 + 显示未读消息数量 博客地址:http://blog.csdn.net/like_program/article/details/53576927
Android仿微信底部菜单栏+顶部菜单栏,可供大家参考学习。
仿微信底部菜单栏 底部菜单字体显示隐藏 底部菜单缩放等等
主要为大家详细介绍了Android仿微信底部菜单栏效果,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
Android 采用TAB的方式实现微信底部菜单,并且配合单击操作实现主界面的文字滚动。 这里创建了ViewPager mViewPager用来放置界面切换,初始化View适配器后,新建ArrayList,用来存放微信底部菜单的4个Tab,四个Tab...
在Android中实现两种主要的Tab效果:... 仿微信底部菜单;2. 仿今日头条顶部导航条。博客讲解见:https://blog.csdn.net/ahuyangdong/article/details/82493158。github源码:https://github.com/ahuyangdong/TabCustom
android高仿微信聊天界面,包含登陆,摇一摇,发信息等多个界面
仿微信底部菜单渐变.rar,太多无法一一验证是否可用,程序如果跑不起来需要自调,部分代码功能进行参考学习。
一款简单,明朗的仿android微信底部菜单的demo。
Android 仿微信圆角菜单、半透明...虽然重在模拟制作微信底部菜单,但是主界面上显示的菜单也是很不错的效果哦,很漂亮。圆角的菜单,测试时可单击“发送图片”按钮,即可滑出半透明的底部菜单,测试效果如抓图所示。
android仿微信6.0底部滑动菜单栏+导航栏,ViewPager+RadioGroup+ActionBar. 有博客描述
仿微信底部和顶部菜单栏 仿微信底部和顶部菜单栏 仿微信底部和顶部菜单栏
Android仿微信界面(包括滑动页、启动页和底部菜单栏等
主要介绍了Android仿微信底部菜单栏功能,并显示未读消息数量,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
仿微信的底部菜单栏,可以进行自定义