0

我有一個標籤小部件在一個活動的底部,其中包含一個圖標和文本,但與我的主題,它只顯示文本。標籤主機在底部問題

我已經看到,這個問題發生在我當前的項目主題是「Theme.AppCompat.Light.NoActionBar」。而我使用「NOTITLEBAR」主題它工作正常,但給我其他問題,由於我不能使用「沒有標題欄」的主題。

我真的不知道爲什麼會發生這種情況。請幫我找到 的錯誤。此外,建議是值得歡迎的。

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); 
     } 


    } 

主題我使用

<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> 

圖片(顯示問題):

enter image description here

回答

0

這是由於發生在底欄的高度,如果通過增加底部欄的高度,然後確保你將看到的圖像讓測試。

+0

你能幫我一些片段嗎? –

+0

讓我們先刪除文本,然後看看你是否能夠看到圖像。 –

+0

好的,我可以在刪除文字後看到圖標 –