Two Panels Layout Animation Android Library

Two Panels Layout Animation Android Library is fully customizable with a drag-gable divider where you can hide and show the fragments in vertical and horizontal and customize the behavior on orientation changes. The library have a slider separating the fragments, you can drag this slider and the fragments resize the views inside.

Two Panels Layout Animation Android Library
Two Panels Layout Animation Android Library

You need to declare in your activity manifest:

android:configChanges="keyboardHidden|orientation|screenSize"

Usage TwoPanelsBaseActivity

public class MainActivity extends TwoPanelsBaseActivity {

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    MyRightFragment mRightFragment = new MyRightFragment();
    MyLeftFragment mLeftFragment = new MyLeftFragment();
    getFragmentManager().beginTransaction().add(R.id.right, mRightFragment).commit();
    getFragmentManager().beginTransaction().add(R.id.left, 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.

Example:

public class MyRightFragment extends RightFragment {

  @Override
  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(R.id.linearRight);
    linearInParent.addView(linear);
    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.
 Hope you enjoy please comment your review below.

By Tell Me How

It is a technology blog and admin has excellent experience in programming from 5+ year. You can contact us at ceo.tellmehow@gmail.com

Share your thoughts

Leave a Reply

Loading Facebook Comments ...
Loading Disqus Comments ...