Git Product home page Git Product logo

centeredcontentbutton's Introduction

Centered Content Button Library

Centered Content Button is Android library which contains following classes:

CenteredContentButton
Represents a button-like component with centered content - icon and/or text. Background and icon resources, text value, text style and typeface can be set in the XML layout file or with set() methods.

See /demo folder for example how to use.

CenteredContentToggleButton
Represents a toggle button-like component with centered content - icon and/or text. Background selector is used to represent selected and not selected states of a button.

See /toggle-demo folder for example how to use.

CenteredContentToggleGroup
Represents a group for toggle button-like components (like RadioGroup for RadioButtons). Can be used to simulate tabs behavior.

See /tabs-demo folder for example how to use.

How to use

A button component is defined in the XML layout file as followed:

<com.skd.centeredcontentbutton.CenteredContentButton
    android:id="@+id/btn"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    ccb:btnBg="@drawable/..."
    ccb:btnIcon="@drawable/..."
    ccb:btnText="@string/..."
    ccb:btnTextStyle="@style/..."
/>
  • android:layout_width - you can also set size in dp
  • android:layout_height - you can also set size in dp
  • ccb:btnBg - background drawable (or selector)
  • ccb:btnIcon - button icon
  • ccb:btnText - button text
  • ccb:btnTextStyle - button text style

A group of toggle buttons is defined in the XML layout file as followed:

<com.skd.centeredcontentbutton.CenteredContentToggleGroup
    android:id="@+id/tabs"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <com.skd.centeredcontentbutton.CenteredContentToggleButton
    	android:id="@+id/tab1"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="0.5"
        ccb:btnBg="@drawable/..."
        ccb:btnChecked="true"
        ccb:btnIcon="@drawable/..."
        ccb:btnText="@string/..."
        ccb:btnTextStyle="@style/..." />

    <com.skd.centeredcontentbutton.CenteredContentToggleButton
        android:id="@+id/tab2"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="0.5"
        ccb:btnBg="@drawable/..."
        ccb:btnIcon="@drawable/..."
        ccb:btnText="@string/..."
        ccb:btnTextStyle="@style/..." />
</com.skd.centeredcontentbutton.CenteredContentToggleGroup>
  • ccb:btnBg - background selector
  • ccb:btnChecked - set button to "checked" state

In order to use components attributes add a namespace definition to the root layout in your XML layout file:

xmlns:ccb="http://schemas.android.com/apk/res-auto"

Button background and icon resources, text value, text style and typeface can also be defined with set() methods.

centeredcontentbutton's People

Contributors

julezzz avatar

Watchers

 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.