2024年最全Android UI-实现底部切换标签(fragment),2024年最新字节跳动三面难吗

最后

今天关于面试的分享就到这里,还是那句话,有些东西你不仅要懂,而且要能够很好地表达出来,能够让面试官认可你的理解,例如Handler机制,这个是面试必问之题。有些晦涩的点,或许它只活在面试当中,实际工作当中你压根不会用到它,但是你要知道它是什么东西。

最后在这里小编分享一份自己收录整理上述技术体系图相关的几十套腾讯、头条、阿里、美团等公司2021年的面试题,把技术点整理成了视频和PDF(实际上比预期多花了不少精力),包含知识脉络 + 诸多细节,由于篇幅有限,这里以图片的形式给大家展示一部分。

还有 高级架构技术进阶脑图、Android开发面试专题资料,高级进阶架构资料 帮助大家学习提升进阶,也节省大家在网上搜索资料的时间来学习,也可以分享给身边好友一起学习。

【Android核心高级技术PDF文档,BAT大厂面试真题解析】

【算法合集】

【延伸Android必备知识点】

【Android部分高级架构视频学习资源】

Android精讲视频领取学习后更加是如虎添翼!进军BATJ大厂等(备战)!现在都说互联网寒冬,其实无非就是你上错了车,且穿的少(技能),要是你上对车,自身技术能力够强,公司换掉的代价大,怎么可能会被裁掉,都是淘汰末端的业务Curd而已!现如今市场上初级程序员泛滥,这套教程针对Android开发工程师1-6年的人员、正处于瓶颈期,想要年后突破自己涨薪的,进阶Android中高级、架构师对你更是如鱼得水,赶快领取吧!

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化学习资料的朋友,可以戳这里获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

android:id=“@+id/ll_bottom_tab”

android:layout_width=“match_parent”

android:layout_height=“54dp”

android:layout_alignParentBottom=“true”

android:gravity=“center_vertical”

android:orientation=“horizontal”

android:baselineAligned=“true”>

<RelativeLayout

android:id=“@+id/rl_know”

android:layout_width=“0dp”

android:layout_height=“wrap_content”

android:layout_weight=“1.0” >

<ImageView

android:id=“@+id/iv_know”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_centerHorizontal=“true”

android:src=“@drawable/btn_know_nor”

android:contentDescription=“@null”/>

<TextView

android:id=“@+id/tv_know”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_below=“@id/iv_know”

android:layout_centerHorizontal=“true”

android:text=“@string/bottom_tab_know”

android:textColor=“@color/bottomtab_normal”

android:textSize=“12sp” />

<RelativeLayout

android:id=“@+id/rl_want_know”

android:layout_width=“0dp”

android:layout_height=“wrap_content”

android:layout_weight=“1.0” >

<ImageView

android:id=“@+id/iv_i_want_know”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_centerHorizontal=“true”

android:src=“@drawable/btn_wantknow_nor”

android:contentDescription=“@null” />

<TextView

android:id=“@+id/tv_i_want_know”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_below=“@+id/iv_i_want_know”

android:layout_centerHorizontal=“true”

android:text=“@string/bottom_tab_wantknow”

android:textColor=“@color/bottomtab_normal”

android:textSize=“12sp” />

<RelativeLayout

android:id=“@+id/rl_me”

android:layout_width=“0dp”

android:layout_height=“wrap_content”

android:layout_weight=“1.0” >

<ImageView

android:id=“@+id/iv_me”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_centerHorizontal=“true”

android:src=“@drawable/btn_my_nor”

android:contentDescription=“@null” />

<TextView

android:id=“@+id/tv_me”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_below=“@+id/iv_me”

android:layout_centerHorizontal=“true”

android:text=“@string/bottom_tab_my”

android:textColor=“@color/bottomtab_normal”

android:textSize=“12sp” />

<LinearLayout

android:id=“@+id/content_layout”

android:layout_width=“match_parent”

android:layout_height=“match_parent”

android:layout_above=“@+id/line”

android:layout_below=“@+id/top_tab”

android:orientation=“vertical” >

<View

android:id=“@+id/line”

android:layout_width=“match_parent”

android:layout_height=“1dp”

android:layout_above=“@id/ll_bottom_tab”

android:background=“@color/line” />

以上是布局代码,下面就介绍如何通过点击标签切换Fragment:

我们会发现,初始的时候是选中第一个标签页,图片和字体的颜色区别于另外两个标签页,所以我们要做的就是切换标签的时候,就改变标签的状态

主要改两个内容:

  • 图片

  • 文字颜色

然后我们切换标签显示的是不同的Fragment,这里我们有三个Fragment,所以我们定义三个不同的Fragment界面:

/BottomTabDemo/src/com/xiaowu/bottomtab/demo/ZhidaoFragment.java

/BottomTabDemo/src/com/xiaowu/bottomtab/demo/IWantKnowFragment.java

/BottomTabDemo/src/com/xiaowu/bottomtab/demo/MeFragment.java

每个Fragment对应不同的布局文件:

/BottomTabDemo/res/layout/main_tab1_fragment.xml

/BottomTabDemo/res/layout/main_tab2_fragment.xml

/BottomTabDemo/res/layout/main_tab3_fragment.xml

ok,这些定义好之后,我们就在主界面上编写切换的代码了,如何对Fragment进行切换呢,定义以下方法:

/**

  • 添加或者显示碎片

  • @param transaction

  • @param fragment

*/

private void addOrShowFragment(FragmentTransaction transaction,

Fragment fragment) {

if (currentFragment == fragment)

return;

if (!fragment.isAdded()) { // 如果当前fragment未被添加,则添加到Fragment管理器中

transaction.hide(currentFragment)

.add(R.id.content_layout, fragment).commit();

} else {

transaction.hide(currentFragment).show(fragment).commit();

}

currentFragment = fragment;

}

完整代码如下:

/BottomTabDemo/src/com/xiaowu/bottomtab/demo/MainActivity.java

package com.xiaowu.bottomtab.demo;

import android.os.Bundle;

import android.support.v4.app.Fragment;

import android.support.v4.app.FragmentActivity;

import android.support.v4.app.FragmentTransaction;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.ImageView;

import android.widget.RelativeLayout;

import android.widget.TextView;

/**

  • 主Activity

  • @author wwj_748

*/

public class MainActivity extends FragmentActivity implements OnClickListener {

// 三个tab布局

private RelativeLayout knowLayout, iWantKnowLayout, meLayout;

// 底部标签切换的Fragment

private Fragment knowFragment, iWantKnowFragment, meFragment,

currentFragment;

// 底部标签图片

private ImageView knowImg, iWantKnowImg, meImg;

// 底部标签的文本

private TextView knowTv, iWantKnowTv, meTv;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

initUI();

initTab();

}

/**

  • 初始化UI

*/

private void initUI() {

knowLayout = (RelativeLayout) findViewById(R.id.rl_know);

iWantKnowLayout = (RelativeLayout) findViewById(R.id.rl_want_know);

meLayout = (RelativeLayout) findViewById(R.id.rl_me);

knowLayout.setOnClickListener(this);

iWantKnowLayout.setOnClickListener(this);

meLayout.setOnClickListener(this);

knowImg = (ImageView) findViewById(R.id.iv_know);

iWantKnowImg = (ImageView) findViewById(R.id.iv_i_want_know);

meImg = (ImageView) findViewById(R.id.iv_me);

knowTv = (TextView) findViewById(R.id.tv_know);

iWantKnowTv = (TextView) findViewById(R.id.tv_i_want_know);

meTv = (TextView) findViewById(R.id.tv_me);

}

/**

  • 初始化底部标签

*/

private void initTab() {

if (knowFragment == null) {

knowFragment = new ZhidaoFragment();

}

if (!knowFragment.isAdded()) {

// 提交事务

getSupportFragmentManager().beginTransaction()

.add(R.id.content_layout, knowFragment).commit();

// 记录当前Fragment

currentFragment = knowFragment;

// 设置图片文本的变化

knowImg.setImageResource(R.drawable.btn_know_pre);

knowTv.setTextColor(getResources()

.getColor(R.color.bottomtab_press));

iWantKnowImg.setImageResource(R.drawable.btn_wantknow_nor);

iWantKnowTv.setTextColor(getResources().getColor(

R.color.bottomtab_normal));

meImg.setImageResource(R.drawable.btn_my_nor);

meTv.setTextColor(getResources().getColor(R.color.bottomtab_normal));

最后

其实Android开发的知识点就那么多,面试问来问去还是那么点东西。所以面试没有其他的诀窍,只看你对这些知识点准备的充分程度。so,出去面试时先看看自己复习到了哪个阶段就好。

下面分享的腾讯、头条、阿里、美团、字节跳动等公司2019-2021年的高频面试题全套解析,博主还把这些技术点整理成了视频和PDF(实际上比预期多花了不少精力),包含知识脉络 + 诸多细节,由于篇幅有限,下面只是以图片的形式给大家展示一部分。

image

知识不体系?这里还有整理出来的Android进阶学习的思维脑图,给大家参考一个方向。

image

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化学习资料的朋友,可以戳这里获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

那么点东西。所以面试没有其他的诀窍,只看你对这些知识点准备的充分程度。so,出去面试时先看看自己复习到了哪个阶段就好。

下面分享的腾讯、头条、阿里、美团、字节跳动等公司2019-2021年的高频面试题全套解析,博主还把这些技术点整理成了视频和PDF(实际上比预期多花了不少精力),包含知识脉络 + 诸多细节,由于篇幅有限,下面只是以图片的形式给大家展示一部分。

[外链图片转存中…(img-JLlKHMRW-1715114042904)]

知识不体系?这里还有整理出来的Android进阶学习的思维脑图,给大家参考一个方向。

[外链图片转存中…(img-PzVRSWaR-1715114042904)]

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化学习资料的朋友,可以戳这里获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

  • 13
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值