यह आपके गतिविधि लेआउट के पदानुक्रमित क्रम के कारण होता है। आपके ActionBar
को आपके व्यू पर खींचा जा रहा है। आप अपनी गतिविधि के फ्रेम को पा सकते हैं और वहां दृश्य जोड़ सकते हैं।
private void addCircleView() {
final FrameLayout frameLayoutRoot = (FrameLayout) getActivity().getWindow()
.getDecorView().findViewById(android.R.id.content);
View circleView = inflater.inflate(
R.layout.my_circle_view, frameLayoutRoot, false);
ViewGroup.MarginLayoutParams marginLayoutParams =
((ViewGroup.MarginLayoutParams) circleView.getLayoutParams());
marginLayoutParams.topMargin = getStatusBarHeight(getActivity())
+ getActivity().getActionBar().getHeight()
+ getResources().getDimensionPixelSize(R.dimen.your_margin_top_circle);
circleView.setLayoutParams(marginLayoutParams);
frameLayoutRoot.addView(circleView);
}
public int getStatusBarHeight(Context context) {
int result = 0;
final int resourceId = context.getResources().getIdentifier(
"status_bar_height", "dimen", "android");
if (resourceId > 0) {
result = context.getResources().getDimensionPixelSize(resourceId);
}
return result;
}
जब आप किसी अन्य टुकड़े पर नेविगेट करते हैं तो दृश्य को हटाना भी याद रखें।
frameLayoutRoot.removeView(circleView);
संपादित करें:
कृपया ध्यान दें कि यह कुछ है कि आप स्तर पर आप ActionBar
जोड़ देते हैं, जो गतिविधि है पर करना चाहिए है। उस स्थिति में आपको इन कामकाज की आवश्यकता नहीं होगी। यह सामान ToolBar
के साथ प्राप्त करने के लिए और अधिक आसान तरीका है।
बनाने और कस्टम दृश्य बढ़ा-चढ़ाकर पहले कोशिश करें, फिर टैब –