【问题标题】:Increasing the tab size?增加标签大小?
【发布时间】:2013-07-27 04:11:09
【问题描述】:

我有这 4 个标签,如下所示。问题是每当我增加标签时,标签大小都会变小。当它们可以简单地水平滚动并且具有相同的大小时,是否有任何解决方案。

 public class MainActivity extends TabActivity {

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);


    setContentView(R.layout.main);

    TabHost tabHost = getTabHost();

    // Tab for Maths
    TabSpec mathspec = tabHost.newTabSpec("Maths");
    mathspec.setIndicator("Maths");
    Intent mathIntent = new Intent(this, MathActivity.class);
    mathspec.setContent(mathIntent);

    // Tab for Units
    TabSpec unitsspec = tabHost.newTabSpec("Units");
    // setting Title and Icon for the Tab
    unitsspec.setIndicator("Units");
    Intent unitsIntent = new Intent(this, UnitsActivity.class);
    unitsspec.setContent(unitsIntent);

    // Tab for Physics
    TabSpec physicsspec = tabHost.newTabSpec("Physics");
    // setting Title and Icon for the Tab
    physicsspec.setIndicator("Physics");
    Intent physicsIntent = new Intent(this, PhysicsActivity.class);
    physicsspec.setContent(physicsIntent);

    // Tab for Chemistry
    TabSpec chemistryspec = tabHost.newTabSpec("Chemistry");
    // setting Title and Icon for the Tab
    chemistryspec.setIndicator("Chemistry");
    Intent chemistryIntent = new Intent(this, ChemistryActivity.class);
    chemistryspec.setContent(chemistryIntent);

    // Adding all TabSpec to TabHost
    tabHost.addTab(mathspec); // Adding maths tab
    tabHost.addTab(unitsspec); // Adding units tab
    tabHost.addTab(physicsspec); // Adding physics tab
    tabHost.addTab(chemistryspec); // Adding chemistry tab

    for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) {
        TextView tv = (TextView) tabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title);
        tv.setTextSize(10);



    }
}
}

【问题讨论】:

    标签: android eclipse android-tabhost tabwidget


    【解决方案1】:

    切换到片段。你永远不会遇到这样的问题。

    请参阅本教程。

    http://wptrafficanalyzer.in/blog/implement-swiping-between-tabs-with-viewpager-in-action-bar-using-sherlock-library/

    此外,标签活动已被弃用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多