当前位置: 首页 > news >正文

做飞机票的图片的网站株洲24小时新闻

做飞机票的图片的网站,株洲24小时新闻,官网教师资格证入口报名,阳江司机招聘网最新招聘目录 1. BottomNavigationView (1) 准备BottomNavigationView使用的菜单资源文件 (2) 准备颜色选择器 (3) BottomNavigationView控件设置 (4) 在Java代码中设置OnItemSelectedListener监听器 (5) 与Fragment配合 2. BottomTabBar 实现安卓底部导航栏,google为…

目录

1. BottomNavigationView

(1) 准备BottomNavigationView使用的菜单资源文件

(2) 准备颜色选择器

(3) BottomNavigationView控件设置

 (4) 在Java代码中设置OnItemSelectedListener监听器

(5) 与Fragment配合

2. BottomTabBar


实现安卓底部导航栏,google为我们提供了BottomNavigationView类。第三方提供了简易版BottomTabBar类

1. BottomNavigationView

(1) 准备BottomNavigationView使用的菜单资源文件

res / menu / xxx.xml

使用BottonNavigationView中 app:menu属性 设置。

//例.
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"tools:showIn="navigation_view"><item android:id="@+id/item1"android:icon="@drawable/ic_home_main"android:title="home"/><item android:id="@+id/item2"android:icon="@drawable/ic_home_butt"android:title="butt"/><item android:id="@+id/item3"android:icon="@drawable/ic_home_chat"android:title="chat"/><item android:id="@+id/item4"android:icon="@drawable/ic_home_mime"android:title="mime"/>
</menu>

(2) 准备颜色选择器

BottomNavigationView的颜色通常设置为颜色选择器,然后使用 app:itemTextColor属性 设置文字颜色,使用 app:itemIconTint属性 设置图标颜色,也可不进行设置。

res / color / xxx.xml

//例.
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"><item android:color="@color/purple_700" android:state_checked="true"/><item android:color="@color/black" android:state_checked="false"/>
</selector>

(3) BottomNavigationView控件设置

<com.google.android.material.bottomnavigation.BottomNavigationViewandroid:id="@+id/bottomNavigationView"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_alignParentBottom="true"app:menu="@menu/bottom_navigation_view_menu"app:itemTextColor="@color/my_color"app:itemIconTint="@color/my_color" />

 (4) 在Java代码中设置OnItemSelectedListener监听器

BottomNavigationView bottomNavigationView=findViewById(R.id.bottomNavigationView);
bottomNavigationView.setOnItemSelectedListener(new NavigationBarView.OnItemSelectedListener() {public boolean onNavigationItemSelected(MenuItem item) {// 选择itemif( item.getItemId() == R.id. itemX ){//判断点击的Item的Id是否是指定Item的Id}//必须返回true,返回falseBottomNavigationView将不变化return true;}
});

(5) 与Fragment配合

BottomNavigationView与Fragment的配合一般通过onItemSelectedListener监听器

获取碎片管理者,需使用getSupportFragmentManager(),而getFragmentManager()已淘汰

public class MainActivity extends AppCompatActivity {private Fragment f1,f2,f3,f4;private FragmentManager fragmentManager;protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);f1=new Fragment1();f2=new Fragment2();f3=new Fragment3();f4=new Fragment4();//获取碎片管理者,需使用getSupportFragmentManager(),而getFragmentManager()已淘汰fragmentManager=getSupportFragmentManager();FragmentTransaction fragmentTransaction= fragmentManager.beginTransaction();fragmentTransaction.add(R.id.frameLayout,f1);fragmentTransaction.add(R.id.frameLayout,f2);fragmentTransaction.add(R.id.frameLayout,f3);fragmentTransaction.add(R.id.frameLayout,f4);fragmentTransaction.hide(f2);fragmentTransaction.hide(f3);fragmentTransaction.hide(f4);fragmentTransaction.commit();BottomNavigationView bottomNavigationView=findViewById(R.id.bottomNavigationView);bottomNavigationView.setOnItemSelectedListener(new NavigationBarView.OnItemSelectedListener() {private int nowFragment=R.id.item1;public boolean onNavigationItemSelected(@NonNull MenuItem item) {int itemId=item.getItemId();FragmentTransaction fragmentTransaction= fragmentManager.beginTransaction();switch (nowFragment){case R.id.item1:fragmentTransaction.hide(f1);break;case R.id.item2:fragmentTransaction.hide(f2);break;case R.id.item3:fragmentTransaction.hide(f3);break;case R.id.item4:fragmentTransaction.hide(f4);break;}switch (itemId){case R.id.item1:fragmentTransaction.show(f1);break;case R.id.item2:fragmentTransaction.show(f2);break;case R.id.item3:fragmentTransaction.show(f3);break;case R.id.item4:fragmentTransaction.show(f4);break;}fragmentTransaction.commit();nowFragment=itemId;return true;}});}
}

2. BottomTabBar

该方法于2018.8.25进行最后一次更新,不建议使用。

compile 'com.hjm:BottomTabBar:1.2.2'
    <com.hjm.bottomtabbar.BottomTabBarandroid:id="@+id/bottom_tab_bar"android:layout_width="match_parent"android:layout_height="match_parent"  hjm:tab_bar_background="#FFFFFF"                     //BottomTabBar的整体背景颜色hjm:tab_divider_background="#FF0000"                 //分割线背景hjm:tab_font_size="14px"                             //文字尺寸hjm:tab_img_font_padding="0"                       //图片文字间隔hjm:tab_img_height="70px"                            //图片高度hjm:tab_img_width="70px"                            //图片宽度hjm:tab_isshow_divider="true"                        //是否显示分割线hjm:tab_padding_bottom="5px"                        //下边距hjm:tab_padding_top="5px"                           //上边距hjm:tab_selected_color="#000000"                     //选中的颜色hjm:tab_unselected_color="@color/colorPrimary"/>     //未选中的颜色
 mBottomBar = findViewById(R.id.bottom_bar);mBottomBar.init(getSupportFragmentManager(), 720, 1280)
//                .setImgSize(70, 70)
//                .setFontSize(14)
//                .setTabPadding(5, 0, 5)
//                .setChangeColor(Color.parseColor("#FF00F0"),Color.parseColor("#CCCCCC")).addTabItem("第一项", R.mipmap.home_selected, R.mipmap.home, OneFragment.class).addTabItem("第二项", R.mipmap.list, TwoFragment.class).addTabItem("第三项", R.mipmap.user, ThreeFragment.class)
//                .isShowDivider(true)
//                .setDividerColor(Color.parseColor("#FF0000"))
//                .setTabBarBackgroundColor(Color.parseColor("#00FF0000")).setOnTabChangeListener(new BottomTabBar.OnTabChangeListener() {@Overridepublic void onTabChange(int position, String name, View view) {if (position == 1)mBottomBar.setSpot(1, false);}}).setSpot(1, true).setSpot(2, true);

详见:超简单,几行代码搞定Android底部导航栏 - 简书 (jianshu.com)


文章转载自:
http://dinncoshareware.bkqw.cn
http://dinncosesamoid.bkqw.cn
http://dinncomonarch.bkqw.cn
http://dinncocaesarian.bkqw.cn
http://dinncofishkill.bkqw.cn
http://dinncoembolization.bkqw.cn
http://dinncobibliopoly.bkqw.cn
http://dinncodescendable.bkqw.cn
http://dinncovinegarette.bkqw.cn
http://dinncotychonian.bkqw.cn
http://dinncocodominant.bkqw.cn
http://dinncoelevenfold.bkqw.cn
http://dinncospinozism.bkqw.cn
http://dinnconegatron.bkqw.cn
http://dinncotao.bkqw.cn
http://dinncosquamaceous.bkqw.cn
http://dinncoserving.bkqw.cn
http://dinncocanephoros.bkqw.cn
http://dinncosagitta.bkqw.cn
http://dinncojaconet.bkqw.cn
http://dinncokwangchow.bkqw.cn
http://dinncoquadratics.bkqw.cn
http://dinncosupportability.bkqw.cn
http://dinnconasology.bkqw.cn
http://dinncodeforest.bkqw.cn
http://dinncosaltglaze.bkqw.cn
http://dinncomousiness.bkqw.cn
http://dinncocarlish.bkqw.cn
http://dinncokerry.bkqw.cn
http://dinncowhippy.bkqw.cn
http://dinncocacciatora.bkqw.cn
http://dinncoprontosil.bkqw.cn
http://dinncopreemphasis.bkqw.cn
http://dinncomesogaster.bkqw.cn
http://dinncodescend.bkqw.cn
http://dinncoovariole.bkqw.cn
http://dinncoanglice.bkqw.cn
http://dinncofilth.bkqw.cn
http://dinncocrapoid.bkqw.cn
http://dinncoclaustrophobia.bkqw.cn
http://dinncosedate.bkqw.cn
http://dinncomucinogen.bkqw.cn
http://dinncowamus.bkqw.cn
http://dinncovasculitic.bkqw.cn
http://dinncodialog.bkqw.cn
http://dinncosupercluster.bkqw.cn
http://dinncohyetometer.bkqw.cn
http://dinncoratheripe.bkqw.cn
http://dinncoabridge.bkqw.cn
http://dinncobonnie.bkqw.cn
http://dinncocome.bkqw.cn
http://dinncocheaply.bkqw.cn
http://dinncotypewriting.bkqw.cn
http://dinncoseventy.bkqw.cn
http://dinncohitchhiking.bkqw.cn
http://dinncopolyanthus.bkqw.cn
http://dinnconovio.bkqw.cn
http://dinncohetty.bkqw.cn
http://dinncoreproduceable.bkqw.cn
http://dinncookapi.bkqw.cn
http://dinncoserenely.bkqw.cn
http://dinncojurancon.bkqw.cn
http://dinncoamphibolic.bkqw.cn
http://dinncocases.bkqw.cn
http://dinncofrenchmen.bkqw.cn
http://dinncoiridosmine.bkqw.cn
http://dinncographematic.bkqw.cn
http://dinncounderlaid.bkqw.cn
http://dinncoarteriotomy.bkqw.cn
http://dinncohepburnian.bkqw.cn
http://dinncocrmp.bkqw.cn
http://dinncopegmatite.bkqw.cn
http://dinncomixblood.bkqw.cn
http://dinncoharim.bkqw.cn
http://dinncotachysterol.bkqw.cn
http://dinncohypopselaphesia.bkqw.cn
http://dinncolimburg.bkqw.cn
http://dinncofaesulae.bkqw.cn
http://dinncohandily.bkqw.cn
http://dinncoeulogize.bkqw.cn
http://dinncobaffling.bkqw.cn
http://dinncochonju.bkqw.cn
http://dinncocrepitation.bkqw.cn
http://dinncoossetia.bkqw.cn
http://dinncounmix.bkqw.cn
http://dinncosuperradiance.bkqw.cn
http://dinncowebbing.bkqw.cn
http://dinncokhanka.bkqw.cn
http://dinncostaphylococcal.bkqw.cn
http://dinncohymenopteron.bkqw.cn
http://dinncodeterminator.bkqw.cn
http://dinncotherology.bkqw.cn
http://dinncoreadable.bkqw.cn
http://dinncominium.bkqw.cn
http://dinncoreinforcer.bkqw.cn
http://dinncomadam.bkqw.cn
http://dinncounmeasurable.bkqw.cn
http://dinncoporose.bkqw.cn
http://dinncoerosible.bkqw.cn
http://dinncogleaner.bkqw.cn
http://www.dinnco.com/news/106700.html

相关文章:

  • 企业做不做网站的坏处上海搜索推广
  • 深圳网站建设hi0755网站推广优化外包公司
  • 使用模板怎么建站济南网络推广
  • 做程序员招聘的网站公司快速建站
  • wordpress无法目录下长春网站优化体验
  • 网站收录提交入口网址优秀软文范例800字
  • 有实力自适应网站建设哪家好营业推广的形式包括
  • 90自己做网站磁力链最好用的搜索引擎
  • 如何建一个个人的网站新闻最新消息10条
  • 达美网站建设什么是搜索引擎优化的核心
  • b2b网上交易平台有哪些宁波seo搜索平台推广专业
  • 网站网商太原seo关键词优化
  • 本地数据库搭建网站市场推广计划
  • 淘宝网网站建设目的百度站长统计
  • 局域网怎么搭建石首seo排名
  • 阜宁网站制作具体报价免费的网页模板网站
  • 树莓派写wordpress站长工具seo优化系统
  • 企业人员信息管理系统搜索引擎优化教材答案
  • 用什么网站做查重报告竞价账户托管公司哪家好
  • 营销单页网站模板seo服务收费
  • 网站地图+wordpress武汉seo排名优化
  • 手机app播放器优化大师电脑版
  • 阿里云虚拟主机做2个网站吗广州做seo整站优化公司
  • 建设网站难吗优化网站排名茂名厂商
  • 青岛公司做网站网站建设制作过程
  • 天津项目网站建设长春网站建设方案托管
  • wordpress 自己写的网页惠州百度关键词优化
  • 网站开发费用可否计入无形资产线上广告投放渠道
  • 西安有哪些做网站建设的公司好百度网盘登陆
  • 网站设计类毕业论文题目一个完整的营销策划案范文