zoukankan      html  css  js  c++  java
  • 实现textview竖排文字效果

    文字效果

    /**
    * @描述
    * @作者 tll
    * @时间 2016/10/20
    */
    public class VerticalTextView extends LinearLayout {
    private LinearLayout llLayout;
    private TextView textView;

    public VerticalTextView(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.context = context;
    color = getResources().getColor(R.color.white);
    View view = LayoutInflater.from(context).inflate(R.layout.vertical_text_view, this, true);
    llLayout = (LinearLayout) view.findViewById(R.id.llLayout);
    textView = (TextView) view.findViewById(R.id.textView);
    }

    private String text;
    private Context context;
    private int color;
    private int size = 20;

    public VerticalTextView(Context context) {
    super(context);
    this.context = context;
    }


    public void setText(String text) {
    this.text = text;
    textView.setText(text);
    }

    public void setTextColor(int color) {
    this.color = color;
    textView.setTextColor(color);
    }

    public void setTextSize(int size) {
    this.size = size;
    textView.setTextSize(size);
    }

    /**
    * 设置背景
    */
    public void setBackground(int resId) {
    llLayout.setBackgroundResource(resId);
    }
    }

    vertical_text_view.xml
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/llLayout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/btn_back"
    android:gravity="center"
    android:orientation="vertical">

    <TextView
    android:id="@+id/textView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#ffffff"
    android:gravity="center_horizontal"
    android:maxWidth="25dp"
    android:textSize="18sp"
    android:text="热门推荐"/>

    </LinearLayout>
     
     
  • 相关阅读:
    iOS开发 | 自定义不规则label
    监控redis的操作命令
    HTML常用标签
    前端学习【第一篇】: HTML内容
    MySQL数据库修改字段的长度
    python模块之:paramiko
    使用pymysql操作mysql数据库
    Python开发【第九篇】: 并发编程
    JNI调用实例
    JVM性能调优入门
  • 原文地址:https://www.cnblogs.com/baiyi168/p/5982140.html
Copyright © 2011-2022 走看看