Skip to content

Switch between different layouts for different states, easily.

Notifications You must be signed in to change notification settings

RajuSE/change-scene

Repository files navigation

change-scene

helps easily switch between different layouts without writing much code of View visibility.

Setup

Add change-scene to your dependencies block:

    compile 'com.github.rajuse.changescene:change-scene:1.1.0'

Usage

ChangeSceneLayout

Add a ChangeSceneLayout to your layout just like any other view.

<dev.raju.lib.changescene.ChangeSceneLayout
        android:id="@+id/rootView"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        
        <!--Your Default-Scene-->
        
</dev.raju.lib.changescene.ChangeSceneLayout>

For example:

    <dev.raju.lib.changescene.ChangeSceneLayout
        android:id="@+id/rootView"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:textColor="@android:color/white" />
    </dev.raju.lib.changescene.ChangeSceneLayout>

To design Default-Scene, there are 3 options: ChangeSceneLayout is custom RelativeLayout ChangeSceneConstraintLayout is custom ConstraintLayout ChangeSceneLinearLayout is custom LinearLayout

methods:

  • Change to your custom layout (custom-scene)
    #changeScene(R.layout.custom_scene);

  • Change to progressbar
    #showProgressScene(String progMessage)

  • Change to default-scene(i.e. childs of ChangeSceneLayout)
    #showContentScene();

Benefits

  • Separates different states with different layouts.
  • You can provide custom layout to be switched to.
  • Progress-scene support for showing progress bar.
  • Boilerplate code related with view visibility/invisibility is gone.

Contributing

As always any enhancements, PRs and bugs report will be highly appreciated. :-)