【问题标题】:Change Properties of Sliding Tab Layout更改滑动选项卡布局的属性
【发布时间】:2015-07-28 03:25:38
【问题描述】:

在下图中

问题 1: 我想在滑动选项卡布局中更改蓝色下划线的颜色和文本(例如 FlashCards)的文本颜色。

我该如何改变呢? 我还想更改 Name 后面的空格:'MyAccount'

问题 2: 当我滑动选项卡时,工具栏(抽认卡)顶部的标题应该会改变。 任何想法如何做到这一点。 我用于布局的 XML 文件如下所示:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent" android:layout_height="match_parent">
    <android.support.v7.widget.Toolbar
        android:id="@+id/tool_bar"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:minHeight="?attr/actionBarSize"
        android:background="@color/colorPrimary"
        >
        <TextView
            android:id="@+id/text_home_screeen"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:textColor="@color/windowBackground"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:layout_marginLeft="10dp"
            android:text="@string/back_title"/>
    </android.support.v7.widget.Toolbar>

<com.example.ojasjuneja.chem.SlidingTabLayout
    android:id="@+id/sliding_tab"
    android:background="@color/colorPrimary"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

</com.example.ojasjuneja.chem.SlidingTabLayout>

<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"

    >

</android.support.v4.view.ViewPager>

</LinearLayout>

【问题讨论】:

    标签: java android android-viewpager pagerslidingtabstrip android-tablayout


    【解决方案1】:

    你需要在你的 XML 中添加 PagerSlidingTabStrip

    <com.astuetz.PagerSlidingTabStrip
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary" />  
    

    并在java文件中添加以下代码..

      PagerSlidingTabStrip tabs = (PagerSlidingTabStrip) rootView.findViewById(R.id.tabs);
                tabs.setViewPager(view_pager);
                tabs.setTextColor(Color.parseColor("#ffffff"));
                tabs.setIndicatorColor(getActivity().getResources().getColor(R.color.sky_blue_color));
    

    【讨论】:

    • 在你的 gradle 文件中添加依赖 compile 'com.jpardogo.materialtabstrip:library:1.1.0'
    【解决方案2】:

    问题 2 当我滑动 Tab 时,工具栏(抽认卡)顶部的标题应该改变。任何想法如何做到这一点。我用于布局的 XML 文件如下所示:

    例如,您需要在 OnCreate() 下方的每个片段中添加一行

    我的列表片段

    ((ActionBarActivity) getActivity()).getSupportActionBar().setTitle("MY LISTS");
    

    我的帐户片段

    ((ActionBarActivity) getActivity()).getSupportActionBar().setTitle("My Account");
    

    【讨论】:

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