私はリストビューと進行状況バーを含むフレームレイアウトを持っています。今、私はリストビューとプログレスバーを持つフレームレイアウトのツールバーレイアウトでナビゲーションドロワを追加しようとしています。 プログレスバーが表示されず、リストビューがツールバーレイアウトの後ろに表示されます。ListViewとProgressbarを持つFrameLayoutにツールバーレイアウトを含める場所
そのは、次のようになります。これを回避するにはenter image description here
:
私は
var toolbar = FindViewById<V7Toolbar>(Resource.Id.toolbar);
を削除
を使用し
<include layout="@layout/toolbar" />
を削除
は
var drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, Resource.String.drawer_open, Resource.String.drawer_close);
Theme.AppCompat.Light.DarkActionBar
から
削除ツールバーのparam SetSupportActionBar(toolbar);
を削除しかし、これで私は引き出しの開閉ボタン(3つの水平線)を失いました。
は、今ではこのようになります - 「リストビューとプログレスバーでフレームレイアウトではツールバーのレイアウトとナビゲーションドロワー」をenter image description here
は誰が追加で私を助けてくださいまたは単に引出しボタンを戻すことができます。
ここは、XAMLコードである:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<android.support.v4.widget.DrawerLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_height="match_parent"
android:layout_width="fill_parent"
android:fitsSystemWindows="true">
<!-- <include layout="@layout/toolbar" /> -->
<ProgressBar
android:id="@+id/progressBar"
style="@android:style/Widget.DeviceDefault.ProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="gone" />
<ListView
android:id="@+id/feedList"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:cacheColorHint="#00000000"
android:dividerHeight="1dp" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_height="match_parent"
android:layout_width="300dp"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header" />
</android.support.v4.widget.DrawerLayout>
</FrameLayout>
テーマスタイル
<!-- Navigation Drawer Theme-->
<style name="Theme.DesignDemo" parent="Base.Theme.DesignDemo">
</style>
<style name="Base.Theme.DesignDemo"
parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#2196F3</item>
<item name="colorPrimaryDark">#1976D2</item>
<item name="android:windowBackground">@color/window_background</item>
</style>
引き出しアクティビティコード:
using Android.Support.V7.App;
using Android.Support.V4.Widget;
using V7Toolbar = Android.Support.V7.Widget.Toolbar;
using Android.Support.Design.Widget;
[Activity (Label = "ANews", Icon = "@drawable/newsicon", Theme =
"@style/Theme.DesignDemo")]
public class MainActivity : AppCompatActivity
{
DrawerLayout drawerLayout;
NavigationView navigationView;
protected override void OnCreate (Bundle bundle){
base.OnCreate (bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.FeedsList);
drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
// Create ActionBarDrawerToggle button and add it to the toolbar
//var toolbar = FindViewById<V7Toolbar>(Resource.Id.toolbar);
//SetSupportActionBar(toolbar);
var drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, Resource.String.drawer_open, Resource.String.drawer_close);
drawerLayout.SetDrawerListener(drawerToggle);
drawerToggle.SyncState();
navigationView = FindViewById<NavigationView>(Resource.Id.nav_view);
setupDrawerContent(navigationView); //Calling Function
}
void setupDrawerContent(NavigationView navigationView)
{
navigationView.NavigationItemSelected += (sender, e) =>
{
e.MenuItem.SetChecked(true);
drawerLayout.CloseDrawers();
};
}
public override bool OnCreateOptionsMenu(IMenu menu)
{
navigationView.InflateMenu(Resource.Menu.nav_menu); //Navigation Drawer Layout Menu Creation
return true;
}
toolbar.axmlコード:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="4dp"
android:background="?attr/colorPrimary" />
</android.support.design.widget.AppBarLayout>
ありがとうございます。
通常、このような問題は、既存のコントロール(または間違ったコントロール)にコントロールを追加しないために発生します。投稿されたコードには追加メソッドはありません。 – jdweng
toolbar.amlコードを投稿してください。 –
@jdweng、私はあなたが説明/コード全体を読んでいないと思います。私はすでに 'SetSupportActionBar(ツールバー);を追加しました。引き出し活動のコード。しかし、回避策のために私はそれをコメントしました。 – xamDev