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>
     
     
  • 相关阅读:
    xhEditor struts2实现图片上传
    xhEditor入门基础
    jQuery全屏插件Textarea Fullscreen
    jQuery幻灯片插件Skippr
    jQuery跳房子插件hopscotch
    合理配置SQLSERVER内存
    浅谈SQL Server 对于内存的管理
    SQL Server 临时表和表变量系列之选择篇
    SQLTest系列之INSERT语句测试
    转:表变量与临时表的优缺点
  • 原文地址:https://www.cnblogs.com/baiyi168/p/5982140.html
Copyright © 2011-2022 走看看