简体   繁体   English

在Android中用文本标记三角形

[英]Label Triangle with text in android

I want to create a label with the triangle shape for cardview as displayed in below image. 我想为卡片视图创建一个三角形的标签,如下图所示。 Is there a way that I can specify a triangle shape in an xml file OR can I achieve it easily with any other way? 有没有一种方法可以在xml文件中指定三角形,还是可以通过其他任何方式轻松实现?

在此处输入图片说明

you can use android:background attribute, to set textview like above 您可以使用android:background属性,像上面一样设置textview

Example: 例:

<android.support.v7.widget.CardView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="10dip" >

    <TextView
        android:id="@+id/Name"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/cal"
        android:ellipsize="end"
        android:gravity="start|center_vertical"
        android:padding="5dp"
        android:singleLine="true"
        android:text="Name"
        android:textColor="@color/darkslate"
        android:textSize="18sp"
        android:textStyle="bold" />
</android.support.v7.widget.CardView >

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM