Coder Social home page Coder Social logo

virendersran01 / realtextview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sockeqwe/realtextview

0.0 0.0 0.0 2.11 MB

A new textview for Android that includes a compilation of libaries to make a real TextView

License: Apache License 2.0

Groovy 2.54% Java 97.46%

realtextview's Introduction

RealTextView

A new TextView for Android that includes a compilation of libraries to make a real TextView. A lot of good libraries out there, but always I had to import each one, why not to merge and improve them in a unique library.

This is what RealTextView does. As well for Button, CheckBox and EditText.

Features:

  • Autofit TextView, set a desired size and a minimun size, and never worry about if a text fits
  • Set any kind of font, only to a textview or set it as a theme for all the TextViews
  • RealTextView and RealButton with indeterminate progress loading
  • HTML text view extension, use RealTextView with html String.

Sample

Get it on Google Play

Example Image Example Image

Usage

dependencies {
    compile 'com.hardsoftstudio.real.textview:library:0.9.0'
}

SDK version >= 14

AutoFit:

The Autofit function is enabled by default with a minimum size of 12dip. If you want to disabled use the real:autoEnabled="false" tag in the XML or by code with the setAutoFit(false).

XML usage:

<com.hardsoftstudio.real.textview.views.RealTextView
            //the normal xml tags
            android:singleLine="true" // or android:maxLines="n" must set a limit in order to compute the autofit
            android:textSize="30sp"
            real:minTextSize="5sp" />

Font:

The RealTextView allows to set custom fonts using assets resources, you can set up just for a TextView or you can set it up as style and theme.

As a theme

    <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
        <item name="fontifyStyle">@style/CustomTextViewStyle</item>
    </style>

    <style name="CustomTextViewStyle">
        <item name="font">@string/app_default_font</item>
    </style>

    <!-- in strings.xml -->
    <string name="app_default_font">fonts/RobotoCondensed-Light.ttf</string>

Just for a textview

<com.hardsoftstudio.real.textview.views.RealTextView
            android:maxLines="2"
            real:font="fonts/Roboto-Black.ttf"
            real:minTextSize="8sp" />

The font can be set from Java code but the good thing of this lib is to avoid setting up the font in java code everytime.

Extended TextView HTML tags

  • <ul>
  • <ol>
  • <dd>
  • <li>
  • <code>
  • <center>

Set HTML

text.setHtmlFromString(
                "<center><h2>You can load images and use center tag</h2>" +
                "<img src=\""+imgUrl+"\"></center>" +
                "<h3>You can list as well</h3>"+
                "<ul>\n" +
                "  <li>Coffee</li>\n" +
                "  <li>Tea</li>\n" +
                "  <li>Milk</li>\n" +
                "</ul>" +
                "<h3>You can use cites and a lot of more tags</h3>" +
                "<p><cite>The Scream</cite> by Edward Munch. Painted in 1893.</p>",false);

In order to correctly display the image, the size must be set. This is an problem of using html in the textview To fix this the best solution approached is this:

String imgUrl = RealUrl.makeImageUrl("Url to any image", 512, 512, Gravity.START);

Must remark that it's not a WebView it's a TextView! So it has it's pros and contras.

Indeterminate progress Text

You can use RealTextView or RealButton to set a Indeterminate text to show a loading efect.

    mRealButton.setIndeterminateLoadingButton(isAnimated,isReverseMode,"Loading...");

The code above will change the text of the Button and make a writing animation forward and backwards if isReverseMode=true

Acknowledgment

This library is a mix of other libraries plus some improvements. Most of the work is made by the following open sources projects:

License

This library is composed by other open source libraries, if used, must include all the license files.

Copyright 2014 Marcel Pintó Biescas

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.

realtextview's People

Contributors

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