GithubHelp home page GithubHelp logo

zhourihu5 / android-horizontaltaillayout Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bosphere/android-horizontaltaillayout

0.0 2.0 0.0 1.41 MB

A simple implementation of a custom layout which solves the issues of grouping a child view with its tailing views.

Java 100.00%

android-horizontaltaillayout's Introduction

Android-HorizontalTailLayout

A simple implementation of a custom layout which solves the issues of grouping a child view with its tailing views.

One example is when right drawable used with TextView. To make sure text is ellipsized properly, we normally want to have TextView extend to match the full width of its parent view, but the drawable would end up showing in the right-most position though having a pretty short length of text.

Another example is when you want to append another TextView after a length-felxible TextView i.e. showing group member count after group name. If group name is really long, we'll want to truncate the group name to leave room for member count. Otherwise we'll want member count to be right next to group name.

Unfortunately there is no straightforward way to implement this using built-in UI widgets.

What HorizontalTailLayout offers:

  • smarter layout in general - guarantee that tailing views to follow closely when there is room for display, and squeeze only the first view otherwise
  • center content without the need of using extra layout wrapper
  • easy to use just like other built-in layouts

Usage

dependencies {
    compile 'com.github.bosphere.android-horizontaltaillayout:horizontaltaillayout:1.0.0'
}
<com.bosphere.horizontaltaillayout.HorizontalTailLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:center="true">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ellipsize="end"
        android:singleLine="true"
        android:includeFontPadding="false"
        android:text="text (center)"/>

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@android:drawable/ic_secure"/>

</com.bosphere.horizontaltaillayout.HorizontalTailLayout>

Compatibility

API 7 (Android 2.1) and up

License

Copyright 2015 Yang Bo

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.

android-horizontaltaillayout's People

Contributors

bosphere avatar

Watchers

James Cloos avatar zhourihu 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.