Two panels layout fully customizable with a draggable divider.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
LibraryTwoPanels Fix bugs Mar 25, 2014
TwoPanelsExample First commit Mar 24, 2014 Update Mar 25, 2014



TwoPanels is a full customizable library where you can hide and show the fragments in vertical and horizontal and customize the behaviour on orientation changes. The library have a slider separating the fragments, you can drag this slider and the fragments resize the views inside.

You need to declare in your activity manifest:


Usage TwoPanelsBaseActivity

public class MainActivity extends TwoPanelsBaseActivity {

	public void onCreate(Bundle savedInstanceState) {
		MyRightFragment mRightFragment = new MyRightFragment();
		MyLeftFragment mLeftFragment = new MyLeftFragment();
		getFragmentManager().beginTransaction().add(, mRightFragment).commit();
		getFragmentManager().beginTransaction().add(, mLeftFragment).commit();
Methods Description
setSlidersDrawables(int verticalDrawable, int horizontalDrawable) Set de drawables for the slider in horizontal and vertical like this example: setSlidersDrawables(R.drawable.slider_vertical, R.drawable.slider_horizontal);
setSliderSize(int size) Set the slider size
switchSliderVisitility(); Set the visivility of the slider with an animate effect.
setBaseOrientation(int orientation) Set the orientation of the panels with the values LinearLayout.VERTICAL or LinearLayout.HORIZONTAL, default is LinearLayout.HORIZONTAL.
slideFragmentsToRight() Slide the fragments to the right with an animation.
slideFragmentsToLeft() Slide the fragments to the left with an animation.
showTwoFragments() Show two panels in the screen.
hideRight() Hide the right panel and show the left panel in full screen.
hideLeft() Hide the left panel and show the right panel in full screen.

Usage RightFragment and LeftFragment

You can use normal fragments or extends from RightFragment and LeftFragment, these fragments have a button for slide the fragments, this button change automatically the drawables on orientation changes of the layout.


public class MyRightFragment extends RightFragment {

	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		super.onCreateView(inflater, container, savedInstanceState);
		LinearLayout linear = new LinearLayout(getActivity());
		LayoutInflater layoutInflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		layoutInflater.inflate(R.layout.myright_fragment, linear, true);
		LinearLayout linearInParent = (LinearLayout) mContainer.findViewById(;
		return this.mContainer;
Methods Description
switchButtonsSliderVisivility() Toggle the visibility of the slider button.
setSliderButtonsDrawables(int, int) Set the drawables of the slider button according orientation of the layout.

Developed By

Antonio Corrales


Copyright 2014 Antonio Corrales

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.