我使用android studio并创建了透明操作栏程序APK。 我使用以下链接中的代码: http://cyrilmottier.com/2013/05/24/pushing-the-actionbar-to-the-next-level/
生成此二进制 XML 文件错误:
JAVA file:
公共(public)类 HomeActivity 扩展了 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);
}
}
最佳答案
试试这个方法,希望能帮助您解决问题。
您忘记更改 xml 中的包名称,例如:
<com.cyrilmottier.android.translucentactionbar.NotifyingScrollView
到
<YourPackageName.NotifyingScrollView
关于java - 二进制 XML 文件行 #2 : Error inflating class com. cyrilmottier.android.translucentactionbar.NotifyingScrollView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26382236/