Coder Social home page Coder Social logo

twopanels's Introduction

TwoPanels

Logo

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:

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.

Developed By

Antonio Corrales [email protected]

License

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

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

twopanels's People

Contributors

desarrolloantonio avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.