A / OpenGLRenderer:错误:环境索引缓冲区溢出

时间:2016-03-14 16:33:22

标签: android android-animation

我在两个片段之间有一张卡片翻转动画,会在动画片中间崩溃。我已经尝试设置动画发生的断点(调试动画的新功能,根据下面的代码告诉我,我应该设置断点)但是我没有任何运气可以确定罪魁祸首。应用程序崩溃时我收到的唯一错误消息如下:

  

A / OpenGLRenderer:错误:环境索引缓冲区溢出!!!使用300,总计298

     

A / libc:致命信号5(SIGTRAP),tid 9338中的代码1(hwuiTask2)

import android.animation.AnimatorInflater;
import android.animation.AnimatorSet;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
public class AnswerActivity extends AppCompatActivity implements FragmentManager.OnBackStackChangedListener {

private AnimatorSet mSetRightOut;
private AnimatorSet mSetLeftIn;

private View mCardFrontLayout;
private View mCardBackLayout;

private Handler mHandler = new Handler();
private boolean mIsBackVisible = false;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_answer_activity);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FragmentManager manager = getFragmentManager();

    if (savedInstanceState == null) {
        FragmentTransaction transaction = manager.beginTransaction();

    //        transaction.add(R.id.q_fragment, questionFragment, "fragmentQ");
        transaction.add(R.id.q_fragment, SingleQuestionFragment.newInstance());
    //        transaction.add(R.id.a_fragment, answerFragment, "fragmentA");
    //            transaction.add(R.id.a_fragment, SingleAnswerFragment.newInstance());
        transaction.add(R.id.a_fragment, new CardFront());
        transaction.commit();

        //right spot?
    //            findViews();
    //            loadAnimations();
    //            changeCameraDistance();

    } else {
        mIsBackVisible = (getFragmentManager().getBackStackEntryCount() > 0);
    }

    getFragmentManager().addOnBackStackChangedListener(this);

}

@Override
protected void onDestroy() {
    super.onDestroy();
}

private void changeCameraDistance() {
    int distance = 8000;
    float scale = getResources().getDisplayMetrics().density * distance;
    mCardFrontLayout.setCameraDistance(scale);
    mCardBackLayout.setCameraDistance(scale);
}

private void loadAnimations() {
    mSetRightOut = (AnimatorSet) AnimatorInflater.loadAnimator(this, R.animator.out_animation);
    mSetLeftIn = (AnimatorSet) AnimatorInflater.loadAnimator(this, R.animator.in_animation);
}

private void findViews() {
    mCardBackLayout = findViewById(R.id.card_back);
    mCardFrontLayout = findViewById(R.id.card_front);
}

public void flipCard(View view) {
//        if (!mIsBackVisible) {
//            mSetRightOut.setTarget(mCardFrontLayout);
//            mSetLeftIn.setTarget(mCardBackLayout);
//            mSetRightOut.start();
//            mSetLeftIn.start();
//            mIsBackVisible = true;
//        } else {
//            mSetRightOut.setTarget(mCardBackLayout);
//            mSetLeftIn.setTarget(mCardFrontLayout);
//            mSetRightOut.start();
//            mSetLeftIn.start();
//            mIsBackVisible = false;
//        }

    if(mIsBackVisible) {
        getFragmentManager().popBackStack();
        return;
    }

    mIsBackVisible = true;

    getFragmentManager()
            .beginTransaction()
    //                .setCustomAnimations(R.anim.new_in_animation, R.anim.new_out_animation)
            .setCustomAnimations(R.animator.in_animation, R.animator.out_animation)
            .replace(R.id.a_fragment, SingleAnswerFragment.newInstance())
            .addToBackStack(null)
            .commit();


}

@Override
public void onBackStackChanged() {
    mIsBackVisible = (getFragmentManager().getBackStackEntryCount() > 0);
}

}

1 个答案:

答案 0 :(得分:2)

我遵循了tufekoi的解决方案,并将我的根布局从cardView更改为FrameLayout,这很简单。