旋转按钮上的文本

adr*_*ian 2 android button

海兰!

我在android上创建了一个按钮,文本看起来像这样:http:landscape//i51.tinypic.com/2u4oaww.png 它看起来像是因为活动处于模式状态.我接下来想要的是旋转文本它看起来正常的按钮,但我可以弄清楚如何做到这一点.

我试过动画,像这样:

res/anim/myanim.xml:

<rotate  xmlns:android="http://schemas.android.com/apk/res/android"
           android:fromDegrees="0" 
           android:toDegrees="180"
           android:pivotX="50%"
           android:duration="0" />

 takePhoto = (Button) findViewById(R.id.btnPhoto);
        takePhoto.setText(t);
        RotateAnimation ranim = (RotateAnimation)AnimationUtils.loadAnimation(this, R.anim.myanim);
          ranim.setFillAfter(true);
        takePhoto.setAnimation(ranim);
Run Code Online (Sandbox Code Playgroud)

但是当我这样做时,我button不再出现在屏幕上了!有人能告诉我怎么能解决这个问题?谢谢

编辑:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" 
android:orientation="horizontal">
    <LinearLayout android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:orientation="vertical"
    android:layout_weight="1.0">
      <SurfaceView  
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
   android:id="@+id/surface_camera"
    />

    </LinearLayout>
    <LinearLayout android:layout_width="90dip"
    android:layout_height="fill_parent">
        <Button 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    android:id="@+id/btnPhoto"
    android:text="Take Photo"
    android:layout_gravity="bottom|left" 
/>
    </LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

Joo*_*ost 5

这应该可以解决问题.

<?xml version="1.0" encoding="utf-8"?>
<rotate  xmlns:android="http://schemas.android.com/apk/res/android"
       android:fromDegrees="0" 
       android:toDegrees="-90"
       android:pivotX="50%"
       android:pivotY="50%"
       android:duration="0" />
Run Code Online (Sandbox Code Playgroud)

首先,似乎你想要将它旋转90 ccw而不是180.另外如果你将持续时间设置为4秒的重要时间,你会发现在你的代码中,按钮将在容器外部转动变得不可见,这就是为什么你我必须在按钮的中心转动.