GithubHelp home page GithubHelp logo

nicbell / material-lists Goto Github PK

View Code? Open in Web Editor NEW
10.0 2.0 1.0 254 KB

An Android XML implementation of Material 3 list items.

License: Apache License 2.0

Kotlin 90.47% Shell 2.79% HTML 6.74%
android kotlin material-design android-library android-ui material

material-lists's Introduction

Material Lists

Maven Central codecov

An Android XML implementation of Material 3 list items.

๐Ÿ™‹๐Ÿฝ Why

Material lists are available in Jetpack Compose but were never implemented in XML. This is a tiny library that aims to provide most examples of this component specified in the design documentation.

I have had to re-implement this layout so many times that I have decided to open-source it.

๐Ÿชœ Setup

Include the dependency in your project.

implementation "net.nicbell.material-lists:listitem:x.x.x"

In order to download the dependency please make sure access to the maven repo is configured. You probably already have Maven Central configured; if you don't you will need to add it.

repositories {
    //..
    mavenCentral()
}

๐Ÿ„๐Ÿฝ Usage

Add the ListItem component to your layout.

Attributes

The following attributes can be changed for a ListItem.

Description Relevant attributes
Headline text app:head
Supporting text app:supportText
Size type - 1, 2 or 3+ lines app:sizeType
Show divider (default true) app:dividerVisible
Divider color app:dividerTint

For more info about size types see the design documentation.

Content

Leading and trailing content can be added as child views. A content style is require in order to position the content correctly within the ListItem.

Description Style Required view type
Leading icon MaterialLists.LeadingIcon AppCompatImageView
Leading image MaterialLists.LeadingImage AppCompatImageView
Leading video thumbnail MaterialLists.LeadingVideoThumbnail AppCompatImageView
Leading avatar image MaterialLists.LeadingAvatar ShapeableImageView
Leading avatar label MaterialLists.LeadingAvatarLabelText MaterialTextView
Leading checkbox MaterialLists.LeadingCheckbox MaterialCheckBox
Leading radio button MaterialLists.LeadingRadioButton MaterialRadioButton
Trailing icon MaterialLists.TrailingIcon AppCompatImageView
Trailing checkbox MaterialLists.TrailingCheckbox MaterialCheckBox
Trailing radio button MaterialLists.TrailingRadioButton MaterialRadioButton
Trailing switch MaterialLists.TrailingSwitch SwitchMaterial or MaterialSwitch
Trailing supporting text MaterialLists.TrailingSupportingText MaterialTextView

Example

<net.nicbell.materiallists.ListItem 
    android:layout_width="match_parent"
    android:layout_height="wrap_content" 
    app:headline="Headline" 
    app:sizeType="TWO_LINES"
    app:supportText="Support text">

    <androidx.appcompat.widget.AppCompatImageView 
        style="@style/MaterialLists.LeadingIcon"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:src="@drawable/ic_outline_person_24" />

    <com.google.android.material.checkbox.MaterialCheckBox
        style="@style/MaterialLists.TrailingCheckbox" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</net.nicbell.materiallists.ListItem>

Which will output the following.

Material 2 compatibility

This library was designed to work with Theme.Material3 themes or themes inheriting from those themes. The reason for this, is that the library leverages some tokens that are only available in Material 3. If your activities use Theme.MaterialComponents themes you can still use the library but you will need to apply a Theme.Material3 theme to the ListItem or one of it's parents in your layout.

Demo

There is a demo app included with many examples.

material-lists's People

Contributors

nicbell avatar dependabot[bot] avatar

Stargazers

Jacob avatar Alexander Starikov avatar  avatar Luis Miguel avatar  avatar  avatar  avatar Jonathan Zopf avatar Claudiu Soare avatar Daniel Beleza avatar

Watchers

 avatar  avatar

Forkers

ksidor93

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.