Reputation: 42824
What i am trying to do:
What is happening:
Question::
Note: i am aware nested way is not advised, but i need to get this architecture
Architecture i am trying to get it:
Upvotes: 3
Views: 2468
Reputation: 1487
At first, you can try this sample from Google https://developer.android.com/samples/SlidingTabsBasic/project.html. It also contains the SlidingTabLayout class, try it, if you use something different.
This project is similar to your (has the same layout) except navigation drawer.
So, let's do the following things:
your main layout may look like this:
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/content_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<LinearLayout
android:id="@+id/drawer"
android:layout_width="@dimen/drawer_width"
android:layout_height="match_parent"
android:layout_gravity="left"
android:background="@color/drawer_back"
android:gravity="left|center_vertical"
android:orientation="vertical">
<ListView
android:id="@+id/left_drawer"
android:layout_width="@dimen/drawer_width"
android:layout_height="0dip"
android:layout_gravity="left"
android:layout_weight="1"
android:background="@color/drawer_back"
android:choiceMode="singleChoice"
android:clipToPadding="false"
android:divider="@android:color/darker_gray"
android:dividerHeight="1dp" />
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
For fragment with sliding tabs use the following layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<yourpackage.slidinglayout.SlidingTabLayout
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"/>
<View
android:layout_width="match_parent"
android:layout_height="4dp"
android:background="@drawable/toolbar_shadow" />
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1"
android:layout_marginTop="@dimen/small_padding"
android:background="@android:color/white"/>
</LinearLayout>
After that you should create a Fragments for your ViewPager and etc. but I think, you've already done it.
Fragment with sliding tabs and ViewPager - it's up to you.
On drawer item with sliding tabs clicked, simple use the FragmentTransaction:
mCurrentFragment = new SlidingTabsFragment();
mTransaction.replace(R.id.content_fragment, mCurrentFragment);
mTransaction.commit();
Upvotes: 1