在層次結構查看器中查看您的視圖。這裏的層次結構(包括ABS的位置)充當視圖層和視圖組的z索引。你可以搶層是動作欄下,並添加自定義視圖到它:
// Grab android.R.id.content's parent to encompass the actionbar & user content
content = ((ViewGroup) findViewById(android.R.id.content).getParent());
// Make sure we inflate our menu resource before it is used
if (dialog == null)
dialog = (ViewGroup) <INFLATE SOME DIALOG/VIEWGROUP HERE>;
// We need this to add a view beneath the action bar
FrameLayout parent = (FrameLayout) content.getParent();
// There needs to be some layout params set for visibility
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, Gravity.TOP);
// A little tricky... using negative margins can do an initial translation that hides a view
layoutParams.setMargins(0, -(heightOfDialog), 0, 0);
dialog.setLayoutParams(layoutParams);
parent.addView(dialog, 0);
這應該允許您定位的對話框下方的視圖,並且仍然能夠製作動畫,你想怎麼用像TranslateAnimation這樣的類:
TranslateAnimation animation = new TranslateAnimation(leftOfContent, 0, 0, 0);
animation.setDuration(TIME_TO_AUTO_SCROLL);
dialog.startAnimation(animation);
這是一個自定義佈局,顯示一個帶有數據和圖像的ListView。 – Wenger 2013-03-05 05:10:41