Android slanted TextView.

Overview

Android Arsenal

SlantedTextView

Android slanted TextView . 中文版

Preview

预览

Gradle

compile 'com.haozhang.libary:android-slanted-textview:1.2'

XML Layout

<com.haozhang.lib.SlantedTextView
    android:layout_width="80dp"
    android:layout_height="80dp"
    android:gravity="center"
    app:slantedBackgroundColor="@color/secondary_text"
    app:slantedLength="40dp"
    app:slantedMode="left"
    app:slantedText="IOS"
    app:slantedTextColor="@color/primary"
    app:slantedTextSize="16sp"
    />

Java

    SlantedTextView stv = (SlantedTextView) findViewById(R.id.test);

    stv.setText("PHP")
            .setTextColor(Color.WHITE)
            .setSlantedBackgroundColor(Color.BLACK)
            .setTextSize(18)
            .setSlantedLength(50)
            .setMode(SlantedTextView.MODE_LEFT);

Attributes

注意

SlantedMode

SlantedMode

License

Copyright 2016 Hand HaoZhang

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.
Comments
  • 布局中如果放在CardView的上层,不显示。

    布局中如果放在CardView的上层,不显示。

    布局代码如下时,不显示SlantedTextView.

    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="200dp"
        app:cardBackgroundColor="@color/white"
        app:cardCornerRadius="5dp"
        app:cardElevation="2dp"
        app:cardMaxElevation="2dp">
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="8dp"
            android:orientation="vertical">
    
            <ImageView
                android:layout_width="80dp"
                android:layout_height="80dp"
                android:scaleType="centerCrop"
                android:src="@drawable/image_default" />
        </LinearLayout>
    </android.support.v7.widget.CardView>
    
    <com.haozhang.lib.SlantedTextView
        android:id="@+id/item_recommend_slanted_tv"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_alignParentRight="true"
        android:gravity="center"
        app:slantedBackgroundColor="#607D88"
        app:slantedLength="40dp"
        app:slantedMode="right"
        app:slantedText="IOS"
        app:slantedTextColor="@color/black"
        app:slantedTextSize="16sp" />
    
    opened by yecaler 7
  • 我想知道我这么设置为什么不显示字呢?谢谢!

    我想知道我这么设置为什么不显示字呢?谢谢!

    <com.haozhang.lib.SlantedTextView android:id="@+id/slantedTextView" android:layout_width="50dp" android:layout_height="50dp" app:slantedText="android" app:slantedLength="30dp" app:slantedMode="left_triangle" app:slantedTextSize="12sp" app:slantedTextColor="@color/colorAccent" app:slantedBackgroundColor="#000000" android:layout_alignTop="@+id/imageView" android:layout_alignEnd="@+id/slantedTextView2" />

    help wanted 
    opened by wdp1990821 6
  • 当背景设置成黄色,字体设置成其他颜色时看不到字,不知道是不是方式不对

    当背景设置成黄色,字体设置成其他颜色时看不到字,不知道是不是方式不对

    @HeZaiJin 当背景设置成黄色,字体设置成其他颜色时看不到字,不知道是不是方式不对

    <com.shtoone.shtw.ui.SlantedTextView android:id="@+id/stv_handle_item_recyclerview_yaliji_fragment_viewpager_fragment" android:layout_width="50dp" android:layout_height="50dp" android:layout_gravity="bottom|right" android:gravity="center" app:slantedBackgroundColor="#ffff00" app:slantedLength="25dp" app:slantedMode="right_bottom_triangle" app:slantedText="未处置" app:slantedTextColor="#000000" app:slantedTextSize="12sp" />

    试过好多种颜色都没用,就是看到黄色背景,看不到字 请问这是Bug吗?

    opened by leguang 4
  • use custom font

    use custom font

    how can i use custom fonts on this widget? for example http://fontawesome.io/cheatsheet/

    my code dont work for example:

    if (!isInEditMode()) {
        if (mTextFontFamily != null || !mTextFontFamily.isEmpty()) {
            mTextTypeFace = Utils.findFont(mContext, mTextFontFamily, mDefaultTextFont);
        } else {
            mTextTypeFace = Utils.findFont(mContext, mDefaultTextFont, null);
        }
    }
    mTextPaint.setTypeface(mTextTypeFace);
    mSlantedText="&#xf032;";
    
    enhancement 
    opened by pishguy 3
  • java.lang.IllegalStateException: SlantedTextView's width must equal to height, w: 96, h: 155

    java.lang.IllegalStateException: SlantedTextView's width must equal to height, w: 96, h: 155

    Hi, thanks for great library, I have a question : I can't use latest your library, always say width and height not equals, but its equal in layout:

     <com.haozhang.lib.SlantedTextView
        android:id="@+id/prStatusTV"
        android:layout_width="48dp"
        android:layout_height="48dp"
        android:layout_alignParentTop="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentLeft="true"
        android:layout_above="@+id/productNameTV"
        android:gravity="center"
        android:text="@string/i_sold_this_pr_txt"
        android:textColor="@color/colorWhite"
        android:fontFamily="sans-serif-condensed"
        app:slantedBackgroundColor="@color/colorAccent"
        app:slantedMode="left_triangle"
        app:slantedText="IOS"
        app:slantedTextColor="@color/colorWhite"
        app:slantedLength="28dp"
        app:slantedTextSize="10sp"
        />
    

    where problem?

    opened by sm-tester 3
  • 关于背景色渐变效果

    关于背景色渐变效果

    您好打扰了,请问一下我想把背景色改成渐变的颜色,要怎么做? mPaint?.shader = LinearGradient( 0f, 0f, w.toFloat(), h.toFloat(), intArrayOf(mSlantedBackgroundGradient[0], mSlantedBackgroundGradient[1]) , null , Shader.TileMode.MIRROR ) 我使用了 shader方法,但是没有起作用, 不知道您最近有没有时间帮忙指导一下,非常感谢

    opened by bilx 2
  • 能否将这个两个属性去掉

    能否将这个两个属性去掉

    <application
        android:allowBackup="true"
        android:supportsRtl="true" >
    </application>
    

    添加了这两个属性后,如果我将这两个属性设置为false,将导致无法编译。

    opened by CCC2016 1
  • Extend from TextView for better usability

    Extend from TextView for better usability

    You should extend from TextView so that we can use the view with TextSwitchers and other stuff that works only with TextViews. I think #1 has a great description on how this may work.

    opened by heinrichreimer 1
  • Fix broken headings in Markdown files

    Fix broken headings in Markdown files

    GitHub changed the way Markdown headings are parsed, so this change fixes it.

    See bryant1410/readmesfix for more information.

    Tackles bryant1410/readmesfix#1

    opened by bryant1410 0
  • Just a few lines to accomplish your results and more

    Just a few lines to accomplish your results and more

    extend from TextView and override the draw method:

    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    public void draw(Canvas canvas) {
        RectF rect = new RectF(ShrinkX, ShrinkY, getMeasuredWidth() - ShrinkX, getMeasuredHeight() - ShrinkY);
    
        if (OffsetX != 0 || OffsetY != 0) {
                canvas.translate(OffsetX, OffsetY);
            }
    
            if (Rotation != 0) {
                canvas.rotate(Rotation, rect.centerX(), rect.centerY());
            }
    
        if (RoundRadius > 0) {
            Path path = new Path();
            path.addRoundRect(rect, RoundRadius, RoundRadius, Path.Direction.CCW);
            canvas.clipPath(path);
        }
    
        paint.setColor(BackColor);
        canvas.drawRect(rect, paint);
    
        super.draw(canvas);
    }
    

    And of course you need to define some variables:

    public int      RoundRadius = 0;
    public int    BackColor   = 0;
    public float    Rotation        = 0f;
    public int    OffsetX           = 0;
    public int    OffsetY           = 0;
    public int      ShrinkX         = 0;
    public int      ShrinkY         = 0;
    
    opened by Youbang 4
Mentions-TextView - Make Mentions and hashtags clickable in Textview

Mentions Textview Custome Textview with Mentions and hashtags being clickable. D

null 2 Jan 9, 2022
Android's TextView that can expand/collapse like the Google Play's app description

ExpandableTextView ExpandableTextView is an Android library that allows developers to easily create an TextView which can expand/collapse just like th

Manabu S. 4k Sep 24, 2022
A library to show emoji in TextView, EditText (like WhatsApp) for Android

Discontinued This projected is discontinued. Please consider using other alternative, i.e EmojiCompat. Contact me if you want to continue working on a

Hieu Rocker 3.6k Sep 29, 2022
Android experiment showing a sinking TextView

Titanic is an Android experiment reproducing this effect.

Romain Piel 1.8k Sep 17, 2022
Advanced Android TextView

Advanced Android TextView Companion app for my Advanced Android TextView talk, demostrating: Animated CompoundDrawable Text shadow Custom font Non-bre

Chiu-Ki Chan 1.2k Aug 10, 2022
This is based on an open source autosizing textview for Android.

SizeAdjustingTextView This is based on an open source autosizing textview for Android I found a few weeks ago. The initial approach didn't resize mult

Elliott Chenger 257 Feb 15, 2022
An extension of Android's TextView, EditText and Button that let's you use the font of your choice

AnyTextView (deprecated) Note: AnyTextView is no longer being maintained. I recommend replacing AnyTextView with the Calligraphy library instead. Frus

Hans Petter Eide 166 Jul 28, 2022
Form validation and feedback library for Android. Provides .setText for more than just TextView and EditText widgets. Provides easy means to validate with dependencies.

android-formidable-validation Form validation and feedback library for Android. Provides .setText for more than just TextView and EditText widgets. Pr

Linden 148 Aug 29, 2022
Simple way to create linked text, such as @username or #hashtag, in Android TextView and EditText

Simple Linkable Text Simple way to create link text, such as @username or #hashtag, in Android TextView and EditText Installation Gradle Add dependenc

Aditya Pradana Sugiarto 77 Aug 27, 2020
Lightweight android library for highlighting sections of a textview, with optional callbacks.

Linker Lightweight android library for highlighting Strings inside of a textview (ignoring case), with optional callbacks. Language: Java MinSDK: 17 J

Josh Gainey 35 Apr 30, 2022
() An Android TextView with a shimmering effect

Shimmer for Android This library is DEPRECATED, as I don't have time to mainatin it anymore. But feel free to go through the code and copy that into y

Romain Piel 2k Sep 18, 2022
An Android TextView that always displays an auto refreshing relative time span with respect to a reference time

android-ago This library provides RelativeTimeTextView, a custom TextView that takes a reference time and always displays the relative time with respe

Kiran Rao 659 Sep 16, 2022
a super textview for android

SuperTextView 重磅推出SuperTextView2.x版本,属性参数相比1.x有些变化,1.x的用户升级2.x的时候请注意 1、功能描述 SuperTextView是一个功能强大的View,可以满足日常大部分布局样式,开发者可已自行组合属性配置出属于自己风格的样式!可能描述起来没有概念

Allen 3.7k Sep 28, 2022
Build valid HTML for Android TextView

HTML Builder Build valid HTML for Android TextView. Description There is a lovely method on the android.text.Html class, fromHtml(), that converts HTM

Jared Rummler 528 Aug 24, 2022
ExpandableTextView - Read More TextView for Android

ExpandableTextView Read More TextView for Android Usage Gradle dependencies { implementation 'com.wayne.expandabletextview:expandable-textview:1.1

You kwangwoo 30 Mar 29, 2022
Animation effects to text, not really textview

HTextView Animation effects with custom font support to TextView see iOS Effects see Flutter Effects Screenshot type gif Scale Evaporate Fall Line Typ

hanks 5.4k Sep 20, 2022
A TextView that automatically resizes text to fit perfectly within its bounds.

AutoFitTextView A TextView that automatically resizes text to fit perfectly within its bounds. Usage dependencies { compile 'me.grantland:autofitt

Grantland Chew 4.2k Sep 14, 2022
A Custom TextView with trim text

ReadMoreTextView A Custom TextView with trim text Download To add the ReadMoreTextView library to your Android Studio project, simply add the followin

Borja B. 1.6k Sep 13, 2022
AutoLinkTextView is TextView that supports Hashtags (#), Mentions (@) , URLs (http://), Phone and Email automatically detecting and ability to handle clicks.

AutoLinkTextView Deprecated Please use the new version of AutoLinkTextView AutoLinkTextView is TextView that supports Hashtags (#), Mentions (@) , URL

Arman 1.1k Sep 20, 2022