Change the layout properties of a sliding tab
Quetion 1: I want to change the blue substring color and text color of the text (like FlashCards) in the sliding tabs layout.
How can I change this? Also I want to change the space following the name: "MyAccount"
Question 2: When I slide the tab, the title at the top of the toolbar (Flashcards) should change. Any idea how to do this. My XML file for layout looks like this:
<?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>
+3
source to share
2 answers
you need to add PagerSlidingTabStrip to your XML
<com.astuetz.PagerSlidingTabStrip
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary" />
and in java file add below code.
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));
+1
source to share
Question 2 When I slide the tab, the title at the top of the Flashcards should change. Any idea how to do this. My XML file for layout looks like this:
You need to add one line to each fragment below OnCreate () like
My snippet list
((ActionBarActivity) getActivity()).getSupportActionBar().setTitle("MY LISTS");
A snippet of my account
((ActionBarActivity) getActivity()).getSupportActionBar().setTitle("My Account");
0
source to share