我的问题是将片段制作成全屏并在其上应用自定义主题。我试过这种方式却无法得到结果。 RssDetailViewFragment.cs包含以下代码行:
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
// Use this to return your custom view for this Fragment
// return inflater.Inflate(Resource.Layout.YourFragment, container, false);
// create ContextThemeWrapper from the original Activity Context with the custom theme
Context contextThemeWrapper = new ContextThemeWrapper(Activity, Android.Resource.Style.ThemeLightNoTitleBarFullScreen);
// clone the inflater using the ContextThemeWrapper
LayoutInflater localInflater = inflater.CloneInContext(contextThemeWrapper);
rootView = localInflater.Inflate(Resource.Layout.RSSFeedDetails, null, false);
// inflate progressbar
progressBar = rootView.FindViewById<ProgressBar>(Resource.Id.progress_bar);
progressBar.Visibility = ViewStates.Visible;
// setting control toolbar
Toolbar toolbar = rootView.FindViewById<Toolbar>(Resource.Id.top_control_toolbar);
((AppCompatActivity)this.Activity).SetSupportActionBar(toolbar);
// setting icon on toolbar
toolbar.SetNavigationIcon(Resource.Drawable.ic_back20);
toolbar.SetBackgroundColor(Resources.GetColor(Resource.Color.primary));
View navigationIcon = toolbar.GetChildAt(1); //NavigationIcon
和我的RssFeedDetals的xml文件是
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="60dp"
android:orientation="vertical"
android:background="@color/viewBackground">
<include
android:id="@+id/top_control_toolbar"
layout="@layout/TopControlToolbar" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/viewBackground">
<WebView
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</ScrollView>
<ProgressBar
android:id="@+id/progress_bar"
style="@android:style/Widget.DeviceDefault.ProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="invisible" />
</LinearLayout>
要问这个问题的主要方法是在Min Sdk 15 plus上使片段全屏显示。
谢谢。
答案 0 :(得分:1)
我想要隐藏app的activity和statusBar工具栏,并用片段视图覆盖该区域。
当您展示RssDetailViewFragment
时,您可以隐藏Statusbar
和Toolbar
,如下所示:
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
SetHasOptionsMenu(true);
//Hide the StatusBar
WindowManagerLayoutParams attr = Activity.Window.Attributes;
attr.Flags = WindowManagerFlags.Fullscreen;
Activity.Window.Attributes = attr;
//Hide the ToolBar
ftoolbar = (V7Toolbar)Activity.FindViewById<V7Toolbar>(Resource.Id.toolbar);
ftoolbar.Visibility = ViewStates.Gone;
//Load views for this Fragment
View view = LayoutInflater.From(Activity).Inflate(Resource.Layout.MGradesView, null);
return view;
}