android animation rotateでなぜか画像が消える

フォーラム(掲示板)ルール
フォーラム(掲示板)ルールはこちら  ※コードを貼り付ける場合は [code][/code] で囲って下さい。詳しくはこちら
LL

android animation rotateでなぜか画像が消える

#1

投稿記事 by LL » 10年前

前の質問が解決しきっておらず申し訳ないのですが。
次の質問を立てさせていただきます。
理由は職業訓練校の授業の内容で起きた原因不明のバグで、これを解決しないと授業が停滞してしまい、深刻な問題になってしまうためです。
(一人でも停滞していると授業が進まないスタイルになっているので・・・)
今回もSBCreativeの基礎からのAndroidからの質問です。
今回はAndroid の アニメーションを使い、画像をスケールしたりトランスレーションしたりしているのですが、
なぜか回転(rotate)だけ結果が回転せず、一瞬画像が消えてそして指定時間後にまた表示されるという不可解な結果になってしまいます。
最初は画像の問題も疑ったのですが度の画像にしても同じバグが発生するのでコードのどこかに問題があると認識しました。
以下、その該当部分のコードです。
Activity

コード:

package jp.denpa.animationsample;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;

public class AnimationSampleActivity extends ActionBarActivity implements View.OnClickListener{

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		
		findViewById(R.id.alpha).setOnClickListener(this);
		findViewById(R.id.rotate).setOnClickListener(this);
		findViewById(R.id.scale).setOnClickListener(this);
		findViewById(R.id.translate).setOnClickListener(this);
	}

	public void onClick(View v){
		Animation animation = null;
		ImageView image1 = (ImageView) findViewById(R.id.dodge);
		switch(v.getId()){
			case R.id.alpha:
				animation = AnimationUtils.loadAnimation(this, R.anim.anim_alpha);
				break;
			case R.id.rotate:
				animation = AnimationUtils.loadAnimation(this, R.anim.anim_rotate);
				break;
			case R.id.scale:
				animation = AnimationUtils.loadAnimation(this, R.anim.anim_scale);
				break;
			case R.id.translate:
				animation = AnimationUtils.loadAnimation(this, R.anim.anim_translate);
				break;
		}
		image1.startAnimation(animation);
	}
	
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.animation_sample, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle action bar item clicks here. The action bar will
		// automatically handle clicks on the Home/Up button, so long
		// as you specify a parent activity in AndroidManifest.xml.
		int id = item.getItemId();
		if (id == R.id.action_settings) {
			return true;
		}
		return super.onOptionsItemSelected(item);
	}
}
該当部分のXML(rotate)

コード:

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="3000"
    android:fromDegrees="0"
    android:toDegrees="360"
    android:pivotX="50%"
    android:pivotY="50%">
</rotate>
恐らく関係ないでしょうがManifestXMLも

コード:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="jp.denpa.animationsample"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="20" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".AnimationSampleActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

LL

Re: android animation rotateでなぜか画像が消える

#2

投稿記事 by LL » 10年前

一つだけ進展です。
他の人が作った、動作確認済みのプロジェクトでも同症状が発生したので、コード側の問題では内という結論に至りました。
仮想環境の設定が悪いのかな・・・
ちなみに仮想デバイスの設定は4.42 API 19です。

ISLe()

Re: android animation rotateでなぜか画像が消える

#3

投稿記事 by ISLe() » 10年前

AVDのデフォルトではPC側のGPU機能を使わない設定になっているはずですが、使う設定に変更すると表示されるかもしれません。

LL

Re: android animation rotateでなぜか画像が消える

#4

投稿記事 by LL » 10年前

ISLe() さんが書きました:AVDのデフォルトではPC側のGPU機能を使わない設定になっているはずですが、使う設定に変更すると表示されるかもしれません。
仮想デバイスの設定でPCのGPU機能を使用する設定にしましたが、変化ありませんでした。
とりあえず、このPCの環境が原因な気がするので解決していませんが解決にチェックをつけておこうかと思います・・・
同じソースで別のPCでは動いていましたので・・・
(あまりこの手の問題を長々と引きずっていると邪魔になるので・・・)

ISLe()

Re: android animation rotateでなぜか画像が消える

#5

投稿記事 by ISLe() » 10年前

LL さんが書きました:(あまりこの手の問題を長々と引きずっていると邪魔になるので・・・)
表示されるPCと表示されないPCの型番とかスペックとか提示されれば、解決しなくとも、有用な情報だと思いますが。

LL

Re: android animation rotateでなぜか画像が消える

#6

投稿記事 by LL » 10年前

ISLe() さんが書きました:
LL さんが書きました:(あまりこの手の問題を長々と引きずっていると邪魔になるので・・・)
表示されるPCと表示されないPCの型番とかスペックとか提示されれば、解決しなくとも、有用な情報だと思いますが。
使用しているPCは全員同じでスペックも同じはずですが一応
使用OS:CentOS
  --リソース:6.5(Final)
  --カーネル:Linux 2.6.32-431.23.3.el6.i686
  --GNOME:2.28.2
ハードウェア
  --メモリ:3.8G
  --プロセッサ0:Intel(R) Pentium(R) 4 CPU 3.00GHz
  --プロセッサ1:Intel(R) Pentium(R) 4 CPU 3.00GHz
必要ないと思いますがディスクの空き容量:43.3G

このPCのOS自体、XPのサポート終了によって入れ替えられた物らしいです。("無料"だから)

ISLe()

Re: android animation rotateでなぜか画像が消える

#7

投稿記事 by ISLe() » 10年前

まったく同じ時期に製造されたまったく同じメーカー型番のPCなのでしょうか。
ビデオチップは違うのではないでしょうかね。

最初からその辺の情報が出てこないとなるとたぶん分からないと思いますけど。

閉鎖

“C言語何でも質問掲示板” へ戻る