GithubHelp home page GithubHelp logo

tribemedia / slidingdrawer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from moraisigor/slidingdrawer

0.0 4.0 0.0 1.11 MB

SlidingDrawer hides content out of the screen and allows the user to drag a handle to bring the content on screen.

License: Apache License 2.0

slidingdrawer's Introduction

1 SlidingDrawer

Android Arsenal

This widget has ported and improved from the Android Open Source Project.

SlidingDrawer hides content out of the screen and allows the user to drag a handle to bring the content on screen, SlidingDrawer can be used vertically or horizontally.

A special widget composed of two children views: the handle, that the users drags, and the content, attached to the handle and dragged with it, SlidingDrawer should be used as an overlay inside layouts, this means SlidingDrawer should only be used inside of a FrameLayout or a RelativeLayout for instance.

The size of the SlidingDrawer defines how much space the content will occupy once slid out so SlidingDrawer should usually use match_parent for both its dimensions.

Inside a XML layout, SlidingDrawer must define the id of the handle and of the content.

See more here SlidingDrawer.

Setup

You can clone this repository like this.

git clone https://github.com/MoraisIgor/SlidingDrawer.git

And add it to your project reference.

For more detailed information, look here Referencing a library project.

Example

In The Layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/holo_red_dark"
    tools:context=".view.MainScreen" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:text="@string/activity"
        android:textColor="@android:color/white"
        android:textSize="25sp" />

    <com.hollowsoft.library.slidingdrawer.SlidingDrawer
        android:id="@+id/sliding_drawer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:content="@+id/drawer_content"
        app:handle="@+id/drawer_handle" >

        <TextView
            android:id="@+id/drawer_handle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@android:color/holo_blue_dark"
            android:gravity="center"
            android:paddingBottom="15dp"
            android:paddingTop="15dp"
            android:text="@string/handle"
            android:textColor="@android:color/white"
            android:textSize="25sp" />

        <TextView
            android:id="@+id/drawer_content"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@android:color/holo_green_dark"
            android:gravity="center"
            android:text="@string/content"
            android:textColor="@android:color/white"
            android:textSize="25sp" />
    </com.hollowsoft.library.slidingdrawer.SlidingDrawer>

</RelativeLayout>
In The Code
public final class MainScreen extends Activity implements OnDrawerScrollListener, OnDrawerOpenListener,
		OnDrawerCloseListener {

	/**
	 *
	 */
	private static final String TAG = "SlidingDrawer";

	/*
	 * (non-Javadoc)
	 *
	 * @see android.app.Activity#onCreate(android.os.Bundle)
	 */
	@Override
	protected void onCreate(final Bundle savedInstance) {
		super.onCreate(savedInstance);

		setContentView(R.layout.main_screen);

		final SlidingDrawer slidingDrawer = (SlidingDrawer) findViewById(R.id.sliding_drawer);

		slidingDrawer.setOnDrawerScrollListener(this);
		slidingDrawer.setOnDrawerOpenListener(this);
		slidingDrawer.setOnDrawerCloseListener(this);
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see
	 * com.hollowsoft.library.slidingdrawer.OnDrawerScrollListener#onScrollStarted
	 * ()
	 */
	@Override
	public void onScrollStarted() {
		Log.i(TAG, "onScrollStarted()");
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see
	 * com.hollowsoft.library.slidingdrawer.OnDrawerScrollListener#onScrollEnded
	 * ()
	 */
	@Override
	public void onScrollEnded() {
		Log.i(TAG, "onScrollEnded()");
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see
	 * com.hollowsoft.library.slidingdrawer.OnDrawerOpenListener#onDrawerOpened
	 * ()
	 */
	@Override
	public void onDrawerOpened() {
		Log.i(TAG, "onDrawerOpened()");
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see
	 * com.hollowsoft.library.slidingdrawer.OnDrawerCloseListener#onDrawerClosed
	 * ()
	 */
	@Override
	public void onDrawerClosed() {
		Log.i(TAG, "onDrawerClosed()");
	}
}

For more detailed information, look at sample application.

Thanks

Awesome tools for code quality improvement:

Contact

License

    Copyright (c) 2014 HollowSoft @IgorMorais
    
    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.
    Copyright (C) 2008 The Android Open Source Project
    
    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.

slidingdrawer's People

Watchers

 avatar  avatar  avatar  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.