如何旋转的TextView? [英] How to Rotate TextView?
本文介绍了如何旋转的TextView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想旋转TextView的,但我不能得到正确的输出。我正在的TextView
缺少一些文本
在布局
< XML版本=1.0编码=UTF-8&GT?;
< RelativeLayout的的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:方向=垂直机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT机器人:layout_marginTop =50dip>
< TextView的Android的:layout_width =WRAP_CONTENT安卓重力=底
机器人:layout_height =WRAP_CONTENT机器人:ID =@ + ID /文
机器人:文本=Shreeji \ñ纳特/>
< / RelativeLayout的>
在动画
< XML版本=1.0编码=UTF-8&GT?;
<旋转的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:fromDegrees =40机器人:toDegrees = - 90机器人:pivotX =40%
机器人:时间=0>
< /旋转>
的Java文件
进口android.app.Activity;
进口android.os.Bundle;
进口android.view.animation.AnimationUtils;
进口android.view.animation.RotateAnimation;
进口android.widget.TextView;
公共类VDemo延伸活动{
/ **第一次创建活动时调用。 * /
@覆盖
公共无效的onCreate(包savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.main);
TextView的电视=(TextView中)findViewById(R.id.text);
RotateAnimation ranim =(RotateAnimation)AnimationUtils.loadAnimation(这一点,R.anim.myanim);
ranim.setFillAfter(真正的);
tv.setAnimation(ranim);
}
}
解决方案
在main.xml中更改为:
< XML版本=1.0编码=UTF-8&GT?;
< RelativeLayout的的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =FILL_PARENT机器人:layout_height =FILL_PARENT>
< TextView的Android版本:layout_alignParentLeft =真
机器人:layout_width =WRAP_CONTENT机器人:layout_height =WRAP_CONTENT
机器人:文本=TextView的机器人:layout_marginTop =50dip
机器人:layout_marginLeft =50dip机器人:ID =@ + ID / text1中的>< / TextView的>
< / RelativeLayout的>
I want to rotate TextView but I can't get proper output. I am getting textView
with missing some text
In Layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_marginTop = "50dip">
<TextView android:layout_width="wrap_content" android:gravity="bottom"
android:layout_height="wrap_content" android:id="@+id/text"
android:text="Shreeji \n Nath" />
</RelativeLayout>
In Animation
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="40" android:toDegrees="-90" android:pivotX="40%"
android:duration="0">
</rotate>
Java file
import android.app.Activity;
import android.os.Bundle;
import android.view.animation.AnimationUtils;
import android.view.animation.RotateAnimation;
import android.widget.TextView;
public class VDemo extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView tv = (TextView)findViewById(R.id.text);
RotateAnimation ranim = (RotateAnimation)AnimationUtils.loadAnimation(this,R.anim.myanim);
ranim.setFillAfter(true);
tv.setAnimation(ranim);
}
}
解决方案
Change the main.xml to :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<TextView android:layout_alignParentLeft="true"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="TextView" android:layout_marginTop="50dip"
android:layout_marginLeft="50dip" android:id="@+id/text1"></TextView>
</RelativeLayout>
这篇关于如何旋转的TextView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文