3
A
回答
2
如果您在活動中獲得ActionBar,則可以將此android:uiOptions =「splitActionBarWhenNarrow」添加到該特定活動的清單中。
這對我有效:)
2
是的,這是可能的,嘗試這個。
public void setActionBArAtBottom(View layoutView, Intent intent,
Context context, ContentValues componentIds) throws Exception {
if (componentIds != null) {
setValues(componentIds);
} else {
System.out
.println("Provide appropriate information to set ActionBar at bottom");
try {
throw new UnsufficientResourcesException();
} catch (UnsufficientResourcesException e) {
e.printStackTrace();
}
}
// getting the parent of screen..actually this is the child of root
// parent...
ViewGroup screenParent = (ViewGroup) layoutView.getParent().getParent();
// now getting actionbarview...as follows...
View actionBArView = ((ViewGroup) screenParent.getChildAt(0))
.getChildAt(0);
// now getting framelayout that is custom layout to display actionbar at
// the bottom...
FrameLayout customActionBarFrameLayout = (FrameLayout) layoutView
.findViewById(BOTTOM_ACTION_BAR_LAYOUT_ID);
// now remove actionbarView from its parent view...
ViewGroup actionBarViewParent = removeFromParent(actionBArView);
removeTitleAndIcon((ViewGroup) actionBArView);
// now setting actionbar view to the framlayout...
customActionBarFrameLayout.addView(actionBArView);
// get the custombar layout....
View customTitleBarLayout = LayoutInflater.from(context).inflate(
NEW_TITLE_BAR_LAYOUT, null);
// setting icon to titile bar...
((ImageView) customTitleBarLayout.findViewById(NEW_TITLE_ICON__ID))
.setImageDrawable(getActivityIcon(intent, context));
// setting title...
((TextView) customTitleBarLayout.findViewById(NEW_TITLE_ID))
.setText(((SherlockActivity) context).getTitle());
// now set this layout to
actionBarViewParent.addView(customTitleBarLayout);
}
// method use to remove child from its parent...
private ViewGroup removeFromParent(View child) {
// removing child...
ViewGroup parentGroup = (ViewGroup) child.getParent();
parentGroup.removeView(child);
return parentGroup;
}
// this method will set application icon to custom title bar layout...
private Drawable getActivityIcon(Intent intent, Context context) {
// getting the current activity icon set...
Drawable drawable = null;
try {
drawable = context.getPackageManager().getActivityIcon(intent);
} catch (NameNotFoundException e) {
e.printStackTrace();
}
return drawable;
}
// remove title and icon from bottombar...
private void removeTitleAndIcon(ViewGroup actionBarViewGroup) {
actionBarViewGroup.removeAllViews();
}
private void setValues(ContentValues contentValues) throws Exception {
try {
BOTTOM_ACTION_BAR_LAYOUT_ID = contentValues
.getAsInteger(BOTTOM_ACTION_BAR_FRAME_LAYOUT_ID);
NEW_TITLE_BAR_LAYOUT = contentValues
.getAsInteger(NEW_TITLE_BAR_LAYOUT_ID);
NEW_TITLE_ICON__ID = contentValues
.getAsInteger(NEW_TITLE_ICON_IMAGEVIEW_ID);
NEW_TITLE_ID = contentValues.getAsInteger(NEW_TITLE_VIEW_ID);
} catch (Exception e) {
throw new UnsufficientResourcesException();
}
}
}
+0
試試這個上面的代碼來獲取任何api級別的底部操作欄,甚至在橫向模式也... –
相關問題
- 1. 是否可以將JViewport的標題行放在底部?
- 2. 是否可以在android中將TabActivity選項卡圖標放在屏幕底部?
- 3. 可以plone將JavaScript放在底部?
- 4. 是否可以在底層放置CAGradientLayer?
- 5. 是否可以將Google Maps V2 MapFragment放入ActionBar選項卡中?
- 6. 是否可以將wx.auiManager窗格放置到其他窗格的頂部/底部?
- 7. 是否可以在ActionBar上使用TransitionDrawable?
- 8. 可以垂直放置Android Actionbar嗎?
- 9. 是否可以在Android ActionBar上添加視圖?
- 10. 底部的ActionBar Sherlock標籤
- 11. 我可以在Android的底部放置一個操作欄嗎?
- 12. 將actionbar sherlock設置爲底部
- 13. ActionBar底部沒有TitleBar
- 14. 將底部跨度放在底部的底部
- 15. 將腳本放在底部
- 16. 底部ActionBar進度條在按鈕
- 17. 在ActionBarActivity底部設置ActionBar選項卡
- 18. 我可以將Ignite UI腳本放在頁面底部嗎?
- 19. Android:是否可以將ArrayList <myObject>放在一個包中?
- 20. Android:如何將listView對齊到自定義actionBar的底部?
- 21. Android:是否可以縮放xml drawable?
- 22. 是否可以在jqgrid的底部添加超鏈接?
- 23. 是否可以在WPF容器底部修剪包裝文本?
- 24. 是否可以讓Vim的completeopt出現在屏幕的底部?
- 25. 實例變量是否可以在類的底部聲明?
- 26. 是否可以將EditText放入LiveWallPaper中?
- 27. 是否可以將標籤放入actionColumn?
- 28. 是否可以將AutoCompeleteBox放入DataForm中?
- 29. Android - 如何在底部添加更多項目ActionBar
- 30. 是否有可能底部Tabview像iphone中的Android?
喜感謝名單是在potrait模式工作正常,但它不工作在橫向模式PLZ標籤和設備給我的解決方案... –
是,它不會在景觀mode.There工作是沒有這樣的規定在android,我們需要做一些黑客或手工代碼.Plz嘗試我上面給出的代碼,它也適用於景觀。 –