Aakash
Aakash

Reputation: 65

Binary XML file line #2: Error inflating class com.cyrilmottier.android.translucentactionbar.NotifyingScrollView

i have use android studio and i create the transparent action bar program APK. i use the code from this below link: http://cyrilmottier.com/2013/05/24/pushing-the-actionbar-to-the-next-level/

this Binary XML file error generate:

JAVA file:

public class HomeActivity extends Activity {

private Drawable mActionBarBackgroundDrawable;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);

    mActionBarBackgroundDrawable = getResources().getDrawable(R.drawable.ab_background);
    mActionBarBackgroundDrawable.setAlpha(0);

    getActionBar().setBackgroundDrawable(mActionBarBackgroundDrawable);

    ((NotifyingScrollView) findViewById(R.id.scroll_view)).setOnScrollChangedListener(mOnScrollChangedListener);
}

private NotifyingScrollView.OnScrollChangedListener mOnScrollChangedListener = new NotifyingScrollView.OnScrollChangedListener() {
    public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) {
        final int headerHeight = findViewById(R.id.image_header).getHeight() - getActionBar().getHeight();
        final float ratio = (float) Math.min(Math.max(t, 0), headerHeight) / headerHeight;
        final int newAlpha = (int) (ratio * 255);
        mActionBarBackgroundDrawable.setAlpha(newAlpha);
    }
};

private Drawable.Callback mDrawableCallback = new Drawable.Callback() {
    @Override
    public void invalidateDrawable(Drawable who) {
        getActionBar().setBackgroundDrawable(who);
    }

    @Override
    public void scheduleDrawable(Drawable who, Runnable what, long when) {
    }

    @Override
    public void unscheduleDrawable(Drawable who, Runnable what) {
    }
};


@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.home, 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);
}

}

Upvotes: 0

Views: 94

Answers (1)

Hareshkumar Chhelana
Hareshkumar Chhelana

Reputation: 24848

Try this way,hope this will help you to solve your problem.

You forget to change package name in xml Like :

<com.cyrilmottier.android.translucentactionbar.NotifyingScrollView

to

<YourPackageName.NotifyingScrollView

Upvotes: 1

Related Questions