由於@wingman在評論中暗示,我在基地Activity
overrided setContentView(...)
這樣的:
@Override
public void setContentView(int layoutResId) {
View view = getLayoutInflater().inflate(layoutResId, null);
setContentView(view);
}
@Override
public void setContentView(View view) {
int wrapContent = ViewGroup.LayoutParams.WRAP_CONTENT;
int matchParent = ViewGroup.LayoutParams.MATCH_PARENT;
view.setLayoutParams(new ViewGroup.LayoutParams(matchParent, matchParent));
View shadow = new View(this);
shadow.setBackgroundResource(R.drawable.action_bar_shadow);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(matchParent,
wrapContent);
shadow.setLayoutParams(params);
RelativeLayout container = new RelativeLayout(this);
container.addView(view);
container.addView(shadow);
super.setContentView(container);
}
要麼你可以改變ActionBarSherlock佈局文件,或創建一個自定義活動類陰影添加到佈局(FrameLayout裏有陰影可繪製),並從中擴展其他活動。 –
謝謝,我會做第二個。我感覺很蠢,現在看起來很明顯:) – fhucho