我在android中有一個活動,我在SurfaceView
下設置了一個按鈕。結果看起來是這樣的: 在android中加載動畫按鈕
而且我對它滿意,除了一件事,按鈕上的文字是錯誤的,必須正確設置。 爲此,我使用的動畫是這樣的:
takePhoto = (Button) findViewById(R.id.btnPhoto);
takePhoto.setText(t);
RotateAnimation ranim = (RotateAnimation)AnimationUtils.loadAnimation(this, R.anim.myanim);
ranim.setFillAfter(true);
takePhoto.setAnimation(ranim);
其中res/anim/myanim
樣子:
<?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" />
但結果有點令人失望,導致整個看起來像:
文字沒問題,但尺寸縮小了。
我想要的是保持正確的文本和初始size.How我可以做到這一點? 它無關的xml文件的原因按鈕的屬性加載動畫....想法時,我並沒有改變他們謝謝...
編輯:xml file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"
>
<SurfaceView android:layout_width="450dip"
android:layout_height="fill_parent" android:id="@+id/surface_camera" />
<RelativeLayout android:layout_width="fill_parent"
android:layout_toRightOf="@id/surface_camera"
android:layout_height="fill_parent"
>
<Button android:layout_width="680dip"
android:layout_height="680dip"
android:id="@+id/btnPhoto"
android:layout_alignParentBottom="true"
android:text="Take Photo"
android:layout_gravity="bottom|right" />
</RelativeLayout>
</RelativeLayout>
IMPORTANT:
In the cases described below...my activity is in `LANDSCAPE` mode and the position of the phone is portrait.Another issue is that when I turn my phone in landscape mode(and here I mean the position of the phone, cause the activity is still landscape) the button doesn't go at the bottom of the phone is stays there.No matter how I turn the phone the button is in the same position!!!!