Tab Host at bottom issue

86 Views Asked by At

I have a tab widget at the bottom of an activity , which consist of an icon and text but with my theme its only showing texts .

I have seen that , this problem occurring which with my current project theme which is "Theme.AppCompat.Light.NoActionBar" . And of i use "NOTITLEBAR" theme it works fine but gives me other problem due to which i cannot use "No TITLE BAR" theme .

i really don't know why this is happening . Please help me in finding bug . Also,suggestion are welcome.

TabWidget.xml

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@android:color/transparent"

    >
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
          android:background="@android:color/white"

     >
     <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="0dip"
            android:layout_weight="1"
              android:background="@android:color/white"


            />
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0"
            android:showDividers="middle"
            android:divider="@color/dividerColor"
              android:background="@color/button_color"
            android:tabStripEnabled="false"


             />

    </LinearLayout>
</TabHost>

TabActivity

public class MainActivity extends TabActivity {

    protected void onCreate(Bundle savedInstanceState) {
            // TODO Auto-generated method stub
            super.onCreate(savedInstanceState);
             setContentView(R.layout.activity_main);

                    // stop executing code by return
                     return;
                }

            context = getApplicationContext();
               // TabHost tabHost = getTabHost();
                tabHost = getTabHost();
                SharedPreferences preferences2 = PreferenceManager.getDefaultSharedPreferences(MainActivity.this);
                String u_id1 = preferences2.getString("Userid","");
                Bean b = new Bean();
                b.setDeviceid(u_id1);

               // tabHost.getTabWidget().getResources().getDrawable(R.drawable.tab); 
             // Tab for Photos
                TabSpec photospec = tabHost.newTabSpec("Favourite");
                photospec.setIndicator("Favorites", getResources().getDrawable(R.drawable.tab_favourites));
            photospec.setContent(photosIntent);


            // Tab for Songs
                TabSpec songspec = tabHost.newTabSpec("Contacts");
                // setting Title and Icon for the Tab

                songspec.setIndicator("Contacts", getResources().getDrawable(R.drawable.tab_contacts));
                Intent songsIntent = new Intent(this, Contacts_new.class);
                songspec.setContent(songsIntent);

                // Tab for Videos
                TabSpec videospec = tabHost.newTabSpec("Meeting");
                videospec.setIndicator("Meeting",getResources().getDrawable(R.drawable.tab_meeting));
                Intent videosIntent = new Intent(this, Meeting.class);
                videospec.setContent(videosIntent);
             // Tab for Future SMS
                TabSpec futuresms = tabHost.newTabSpec("Map");
                futuresms.setIndicator("Map",getResources().getDrawable(R.drawable.tab_map));
                Intent futureIntent = new Intent(this, Map.class);
                futuresms.setContent(futureIntent);
                // Tab for Future SMS
                TabSpec setting = tabHost.newTabSpec("Setting");
                setting.setIndicator("Setting",getResources().getDrawable(R.drawable.tab_setting));
                Intent settingintent = new Intent(this, Setting.class);
                setting.setContent(settingintent);

            // Adding all TabSpec to TabHost
                tabHost.addTab(photospec); // Adding photos tab
                tabHost.addTab(songspec); // Adding songs tab
                tabHost.addTab(videospec); // Adding videos tab
                tabHost.addTab(futuresms);
                tabHost.addTab(setting);

            for (int j=0;j<tabHost.getTabWidget().getChildCount();j++){
                TextView textView = (TextView)tabHost.getTabWidget().getChildAt(j).findViewById(android.R.id.title);
                textView.setTextSize(5);

            }


            for (int i = 0; i <tabHost.getTabWidget().getChildCount(); i++) {
                tabHost.getTabWidget().getChildTabViewAt(i).setBackgroundColor(getResources().getColor(R.color.button_color));

            }

               String tabid = Bean.getDeviceid();
               if(tabid == null)
               {
                   int in = Integer.parseInt("2");
                    tabHost.setCurrentTab(in);
               }
               else
               {
                int in = Integer.parseInt(tabid);
                tabHost.setCurrentTab(in);
               }
             }  
        @Override
        protected void onDestroy() {
            // TODO Auto-generated method stub
             SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
              SharedPreferences.Editor editor = preferences.edit();
              editor.putString("msg","Hi");

            super.onDestroy();
        }



        @Override
        public void onBackPressed() {
            // TODO Auto-generated method stub
            super.onBackPressed();
            System.gc();
            MainActivity.this.finish();
            System.exit(0);
        }


    }

Theme i am using

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="colorPrimary">@color/green_top_bar</item>
        <item name="colorPrimaryDark">@color/green_top_bar</item>
        <item name="colorControlNormal">#ECEFF1</item>
        <!--<item name="colorAccent"></item>-->
        <item name = "android:textColorSecondary">#727272</item>

Image(showing issue) :

enter image description here

1

There are 1 best solutions below

6
Amit Yadav On

This is happening due to the height of the bottom bar lets test if by increasing the height of bottom bar, then sure your will see the image.