Want to imitate the open source Chinese source code to realize the FragmentTabHost to realize the bottom column, but has not been able to realize it? (Passer Passer’s Great God Watch)

  android, question

To achieve this effect:

clipboard.png
This is what I did when I was a scumbag: (What the hell)

clipboard.png

MainACtivity

public class MainActivity extends AppCompatActivity implements View.OnClickListener,
 View.OnTouchListener, TabHost.OnTabChangeListener {
 
 @InjectView(android.R.id.tabhost)
 MyFragmentTabHost mTabHost;
 @InjectView(R.id.iv_quick_option)
 ImageView ivQuickOption;
 
 
 @Override
 public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);
 Log.d("MainActivity", "OnCreate");
 ButterKnife.inject(this);
 initView();
 bracket
 
 private void initView() {
 
 mTabHost.setup(MainActivity.this, getSupportFragmentManager(), R.id.realtabcontent);
 if (android.os.Build.VERSION.SDK_INT > 10) {
 mTabHost.getTabWidget().setShowDividers(0);
 bracket
 initTabs();
 
 //middle key picture trigger
 ivQuickOption.setOnClickListener(this);
 
 mTabHost.setCurrentTab(0);
 mTabHost.setOnTabChangedListener(this);
 bracket
 
 private void initTabs() {
 MainTab[] tabs = MainTab.values();
 final int size = tabs.length;
 Log.d("MainActivity", "Tab "plus size);
 for (int i = 0;   i < size;  I plus)
 MainTab mainTab = tabs[i];
 TabSpec tab = mTabHost.newTabSpec(getString(mainTab.getResName()));
 View indicator = LayoutInflater.from(getApplicationContext()).inflate(R.layout.tab_indicator, null);
 TextView title = (TextView) indicator.findViewById(R.id.tab_title);
 Drawable drawable = this.getResources().getDrawable(mainTab.getResIcon());
 title.setCompoundDrawablesWithIntrinsicBounds(null, drawable, null, null);
 if (i == 1) {
 indicator.setVisibility(View.INVISIBLE);
 mTabHost.setNoTabChangedTag(getString(mainTab.getResName()));
 bracket
 title.setText(getString(mainTab.getResName()));
 tab.setIndicator(indicator);
 tab.setContent(new TabContentFactory() {
 @Override
 public View createTabContent(String tag) {
 return new View(MainActivity.this);
 bracket
 });
 mTabHost.addTab(tab, mainTab.getCls(), null);
 
 mTabHost.getTabWidget().getChildAt(i).setOnTouchListener(this);
 bracket
 bracket
 
 @Override
 public void onClick(View v) {
 int id = v.getId();
 if (id == R.id.iv_quick_option) {
 Toast.maketext (mainactivity.this, "hey hey", Toast.LENGTH_SHORT).show ();
 bracket
 
 bracket
 
 @Override
 public boolean onTouch(View v, MotionEvent event) {
 return false;
 bracket
 
 @Override
 public void onTabChanged(String tabId) {
 
 bracket
 bracket

activity_main.xml

<?  xml version="1.0" encoding="utf-8"?  >
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:orientation="vertical"
 tools:context="com.jack.musicandchat.activity.MainActivity">
 <!  -manage fragments->
 <FrameLayout
 Android:id="@ plus id/realtabcontent "
 android:layout_width="match_parent"
 android:layout_height="0dp"
 android:layout_weight="1" />
 
 <FrameLayout
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:background="@color/windows_bg">
 
 <RelativeLayout
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:layout_marginBottom="4dip">
 
 <com.jack.musicandchat.widget.MyFragmentTabHost
 android:id="@android:id/tabhost"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:layout_marginTop="4dip" />
 
 <View
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:background="@color/div_white" />
 </RelativeLayout>
 
 <!  -quick operation button->
 <ImageView
 Android:id="@ plus id/iv_quick_option "
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_gravity="center"
 android:contentDescription="@null"
 android:src="@drawable/tab_icon_quick" />
 </FrameLayout>
 </LinearLayout>

MainTab.java

public enum MainTab {
 MUSIC(0, R.string.main_tab_name_music, R.drawable.tab_icon_music, MusicFragment.class),
 
 QUICK(1, R.string.main_tab_name_quick, R.drawable.tab_icon_quick, null),
 
 CHAT(2, R.string.main_tab_name_chat, R.drawable.tab_icon_chat, ChatFragment.class);
 
 private int idx;
 private int resName;
 private int resIcon;
 private Class<?  > cls;
 
 private MainTab(int idx, int resName, int resIcon, Class<?  > cls) {
 this.idx = idx;
 this.resName = resName;
 this.resIcon = resIcon;
 this.cls = cls;
 bracket
 
 public int getIdx() {
 return idx;
 bracket
 
 public void setIdx(int idx) {
 this.idx = idx;
 bracket
 
 public int getResName() {
 return resName;
 bracket
 
 public void setResName(int resName) {
 this.resName = resName;
 bracket
 
 public int getResIcon() {
 return resIcon;
 bracket
 
 public void setResIcon(int resIcon) {
 this.resIcon = resIcon;
 bracket
 
 public Class<?  > getCls() {
 return cls;
 bracket
 
 public void setCls(Class<?  > cls) {
 this.cls = cls;
 bracket
 bracket

Generally, the bottom navigation bar is implemented by using a linear layout as the bottom navigation bar in the layout file inside corresponding to an activity. The linear layout style is your bottom navigation bar style, and all the parts above the linear layout are reserved for adding different fragment, that is, the pages in your navigation bar.