关于testView的背景旋转
来源:互联网 发布:淘宝网店怎么找货源 编辑:程序博客网 时间:2024/06/05 00:46
Android之TextView实现倾斜文字
分类: android2013-04-20 22:51 138人阅读 评论(2) 收藏 举报
Androidtextview布局Canvas
效果图
java代码RotateTextView
- import android.content.Context;
- import android.graphics.Canvas;
- import android.util.AttributeSet;
- import android.widget.TextView;
- public class RotateTextView extends TextView {
- private static final String NAMESPACE = "http://www.ywlx.net/apk/res/easymobi";
- private static final String ATTR_ROTATE = "rotate";
- private static final int DEFAULTVALUE_DEGREES = 0;
- private int degrees;
- public RotateTextView(Context context, AttributeSet attrs) {
- super(context, attrs);
- degrees = attrs.getAttributeIntValue(NAMESPACE, ATTR_ROTATE,
- DEFAULTVALUE_DEGREES);
- }
- @Override
- protected void onDraw(Canvas canvas) {
- canvas.rotate(degrees, getMeasuredWidth() / 2, getMeasuredHeight() / 2);
- super.onDraw(canvas);
- }
- }
xml布局文件
- <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:easymobi="http://www.ywlx.net/apk/res/easymobi"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
- <com.example.test.RotateTextView
- android:id="@+id/tvBottom_color"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:background="#00FF00"
- android:layout_centerInParent="true"
- android:padding="15dip"
- android:textColor="#000"
- android:textSize="30dip"
- android:text="倾斜文字"
- easymobi:rotate = "10"/>
- </RelativeLayout>
注 : easymobi:rotate=”10″指定了旋转10度,但是要注意在头文件加上 xmlns:easymobi=”http://www.ywlx.net/apk/res/easymobi”,这个就是RotateTextView 中的命名空间的作用,其他属性与普通的TextView相同。还有一点要注意的就是加上合适的padding,因为这种方法旋转的是TextView里面的字,而不是TextView本身,如果 不加padding,有些字就会因为旋转而跑到了TextView外面而不能显示。
com.example.test.RotateTextView为RotateTextView在项目中的路径
很多博客用这种方法实现了文字旋转, 但是背景旋转呢
求高手赐教
0 0
- 关于testView的背景旋转
- 圆角TestView的实现
- 旋转的星空背景
- 关于listview显示问题,点击item选项areaBtn这个testview里面不显示areaBtn2的testview可以显示求大神帮忙。谢谢!!!
- 给TestView周期性的设置text
- css3.0实现背景旋转的方法
- 变换色彩的旋转图形----背景效果
- 关于旋转的动画
- 关于Bitmap的旋转
- 关于tableview的旋转
- 关于视图的旋转
- 关于AlertDialog的背景
- 关于UITableViewCell的背景
- TestView的autoLink属性和跑马灯marquee的属性
- 360度不停旋转的10片叶子背景---纯css实现旋转背景
- 我写过的软件之UniversalHst-TestView
- 我写过的软件之LoaderHst-TestView
- Android TestView实现跑马灯效果的两种方法
- 查找ArrayList元素的下标
- A*搜索算法
- 黑马程序员——学习笔记10.Java网络编程
- ubuntu 软件安装常见错误
- Linux学习笔记 - 軟體安裝: RPM, SRPM
- 关于testView的背景旋转
- 用C实现模拟图灵机进行两个数的加法运算
- 块设备驱动编写总结一(ZT)
- ORACLE锁机制
- V8引擎嵌入指南
- G7刷机
- [Other]规范的邮件签名格式及HTML代码
- 2014进度 1-2 月
- Android AlertDialog使用