【问题标题】:How to increase height of tab indicator如何增加标签指示器的高度
【发布时间】:2015-10-25 09:04:18
【问题描述】:

我创建了 3 个标签。 但是当我在选项卡之间切换时,选项卡指示器的高度非常小,它就像选项卡上的一条细线。我还没有看到任何可以解决这个问题的帖子。所有这些都是关于如何更改选项卡的颜色指标。

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_ACTION_BAR);
    try {

        setContentView(R.layout.activity_main);
        ActionBar bar = getActionBar();

        Log.d("In Tab Activity", bar.toString());
        bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        Tab tab1 = bar.newTab();
        tab1.setText("Contacts");
        tab1.setTabListener(this);
        bar.addTab(tab1);




        Tab tab2 = bar.newTab();
        tab2.setText("Messages");
        tab2.setCustomView(TabUtils.renderTabView(this, R.string.tab_invitations, R.drawable.ic_add_alert_black_24dp, 5));
        tab2.setTabListener(this);
        bar.addTab(tab2);


        Tab tab3 = bar.newTab();
        tab3.setText("History");
        tab3.setTabListener(this);
        bar.addTab(tab3);

        webView = (WebView) findViewById(R.id.webPage);
        jSInterface = new AndroidJSInterface(this);
        webView.addJavascriptInterface(jSInterface, "AndroidJSInterface");

        webView.loadUrl("file:///android_asset/HybridPage2.html", null);

        /*
         * Fragment main = new MainFragment(); FragmentTransaction ft =
         * getFragmentManager().beginTransaction();
         * ft.replace(R.id.content_frame, main);
         * ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
         * ft.addToBackStack(null); ft.commit();
         */
    } catch (Exception e) {
        Log.d("Exception is", e.getMessage());
    }
}

【问题讨论】:

  • 你能展示你的代码或者图片什么的吗?
  • 显示标签栏实现的代码
  • 我已经编辑了我的帖子。
  • 您使用的是哪个主题?即你的活动主题或styles.xml中提到的完整应用程序?
  • 你找到解决办法了吗?

标签: android


【解决方案1】:

您可以在 TabLayout 下的 xml 文件中通过 app:tabIndicatorHeight=".." 指定选项卡指示器的高度。

【讨论】:

  • 这应该是公认的答案,可以按预期解决问题
【解决方案2】:

使用新的设计库并参考以下代码。您可以更改 TabLayout 的宽度来更改 TAB 的高度。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <android.support.v7.widget.Toolbar
        android:id="@+id/tab_toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/accent_material_light" />

    <android.support.design.widget.TabLayout
        android:id="@+id/tablayout"
        android:layout_width="match_parent"
        android:background="@color/accent_material_dark"
        android:layout_height="200dp" />

</android.support.design.widget.AppBarLayout>

【讨论】:

  • 我不想改变标签的高度。我想改变当我们点击标签时出现的 TAB INDICATOR 的高度。
猜你喜欢
  • 2021-10-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多