android 仿微博底部菜单弹出效果,仿新浪微博底部菜单TabHost-Fun言

效果图:

1.

main.xml文件的内容:

android:id=”@android:id/tabhost”

android:layout_width=”fill_parent”

android:layout_height=”fill_parent”

>

android:orientation=”vertical”

android:layout_width=”fill_parent”

android:layout_height=”fill_parent”>

android:id=”@android:id/tabcontent”

android:layout_width=”fill_parent”

android:layout_height=”0.0dip”

android:layout_weight=”1.0″/>

android:id=”@android:id/tabs”

android:layout_width=”fill_parent”

android:layout_height=”wrap_content”

android:layout_weight=”0.0″

android:visibility=”gone”/>

android:id=”@+id/main_tab”

android:background=”@drawable/maintab_toolbar_bg”

android:orientation=”horizontal”

android:layout_width=”fill_parent”

android:layout_height=”wrap_content”

android:gravity=”center_vertical”

android:layout_gravity=”bottom”>

android:layout_marginTop=”2.0dip”

android:text=”@string/main_home”

android:drawableTop=”@drawable/icon_1_n”

android:id=”@+id/radio_button0″

style=”@style/main_tab_bottom”/>

android:layout_marginTop=”2.0dip”

android:text=”@string/main_news”

android:drawableTop=”@drawable/icon_2_n”

android:id=”@+id/radio_button1″

style=”@style/main_tab_bottom”/>

android:layout_marginTop=”2.0dip”

android:text=”@string/main_my_info”

android:drawableTop=”@drawable/icon_3_n”

android:id=”@+id/radio_button2″

style=”@style/main_tab_bottom”/>

android:layout_marginTop=”2.0dip”

android:text=”@string/menu_search”

android:drawableTop=”@drawable/icon_4_n”

android:id=”@+id/radio_button3″

style=”@style/main_tab_bottom”/>

android:layout_marginTop=”2.0dip”

android:text=”@string/more”

android:drawableTop=”@drawable/icon_5_n”

android:id=”@+id/radio_button4″

style=”@style/main_tab_bottom”/>

2.

MainTabActivity.java文件内容:

package com.jun.demo2;

import android.app.TabActivity;

import android.content.Intent;

import android.os.Bundle;

import android.view.Window;

import android.widget.RadioGroup;

import android.widget.TabHost;

import android.widget.RadioGroup.OnCheckedChangeListener;

import android.widget.Toast;

public class MainTabActivity extends TabActivity implements OnCheckedChangeListener{

private RadioGroup mainTab;

private TabHost tabhost;

private Intent iHome;

private Intent iNews;

private Intent iInfo;

private Intent iSearch;

private Intent iMore;

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

requestWindowFeature(Window.FEATURE_NO_TITLE);

setContentView(R.layout.main);

mainTab=(RadioGroup)findViewById(R.id.main_tab);

mainTab.setOnCheckedChangeListener(this);

tabhost = getTabHost();

//        在此进行Intent的初始化,设置Intent将传进那个Activity

//        iHome = new Intent(this, HomeActivity.class);

//        tabhost.addTab(tabhost.newTabSpec(“iHome”)

//                .setIndicator(getResources().getString(R.string.main_home), getResources().getDrawable(R.drawable.icon_1_n))

//                .setContent(iHome));

//

//        iNews = new Intent(this, NewsActivity.class);

//        tabhost.addTab(tabhost.newTabSpec(“iNews”)

//                .setIndicator(getResources().getString(R.string.main_news), getResources().getDrawable(R.drawable.icon_2_n))

//                .setContent(iNews));

//

//        iInfo = new Intent(this, MyInfoActivity.class);

//        tabhost.addTab(tabhost.newTabSpec(“iInfo”)

//                .setIndicator(getResources().getString(R.string.main_my_info), getResources().getDrawable(R.drawable.icon_3_n))

//                .setContent(iInfo));

//

//        iSearch = new Intent(this,SearchActivity.class);

//        tabhost.addTab(tabhost.newTabSpec(“iSearch”)

//                .setIndicator(getResources().getString(R.string.menu_search), getResources().getDrawable(R.drawable.icon_4_n))

//                .setContent(iSearch));

//

//        iMore = new Intent(this, MoreActivity.class);

//         tabhost.addTab(tabhost.newTabSpec(“iMore”)

//                    .setIndicator(getResources().getString(R.string.more), getResources().getDrawable(R.drawable.icon_5_n))

//                    .setContent(iMore));

}

@Override

public void onCheckedChanged(RadioGroup group, int checkedId) {

switch(checkedId){

case R.id.radio_button0:

Toast.makeText(MainTabActivity.this,”button0″,Toast.LENGTH_SHORT).show();

break;

case R.id.radio_button1:

Toast.makeText(MainTabActivity.this,”button1″,Toast.LENGTH_SHORT).show();

break;

case R.id.radio_button2:

Toast.makeText(MainTabActivity.this,”button2″,Toast.LENGTH_SHORT).show();

break;

case R.id.radio_button3:

Toast.makeText(MainTabActivity.this,”button3″,Toast.LENGTH_SHORT).show();

break;

case R.id.radio_button4:

Toast.makeText(MainTabActivity.this,”button4″,Toast.LENGTH_SHORT).show();

break;

}

}

}

3.string.xml文件内容:

SinaWeibo

首页

信息

我的资料

搜索

更多

4.drawables.xml文件的内容:

#00000000

5.dimens.xml文件的内容:

2.0dip

5.0dip

10.0dip

6.styles.xml文件内容:

@dimen/bottom_tab_font_size

#ffffffff

marquee

center_horizontal

@drawable/home_btn_bg

@dimen/bottom_tab_padding_up

fill_parent

wrap_content

@null

true

@dimen/bottom_tab_padding_drawable

1.0

7。res/drawable下文件home_btn_bg.xml内容:设置按钮被选中时颜色

xmlns:android=”http://schemas.android.com/apk/res/android”>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值