2017-06-21 6 views
0

私はリストビューと進行状況バーを含むフレームレイアウトを持っています。今、私はリストビューとプログレスバーを持つフレームレイアウトのツールバーレイアウトでナビゲーションドロワを追加しようとしています。 プログレスバーが表示されず、リストビューがツールバーレイアウトの後ろに表示されます。ListViewとProgressbarを持つFrameLayoutにツールバーレイアウトを含める場所

そのは、次のようになります。これを回避するにはenter image description here

  • 私はvar toolbar = FindViewById<V7Toolbar>(Resource.Id.toolbar);

  • を削除 Theme.AppCompat.Light.DarkActionBar

  • を使用し<include layout="@layout/toolbar" />

  • を削除

  • var drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, Resource.String.drawer_open, Resource.String.drawer_close);

から

  • 削除ツールバーの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> 
    

    ありがとうございます。

  • +0

    通常、このような問題は、既存のコントロール(または間違ったコントロール)にコントロールを追加しないために発生します。投稿されたコードには追加メソッドはありません。 – jdweng

    +0

    toolbar.amlコードを投稿してください。 –

    +0

    @jdweng、私はあなたが説明/コード全体を読んでいないと思います。私はすでに 'SetSupportActionBar(ツールバー);を追加しました。引き出し活動のコード。しかし、回避策のために私はそれをコメントしました。 – xamDev

    答えて

    0

    プログレスバーが表示されず、リストビューがツールバーレイアウトの後ろに表示されます。

    documentが言ったようので、あなたのProgressBarListViewLinearLayoutまたはRelativeLayoutToolbarを入れて:それは子供たちがそれぞれの重複の方法で子供viewsを整理するため FrameLayoutは、単一の子ビューを保持するために使用する必要がありますその他。

    ツールバーでコードを変更します。AXML:

    <android.support.design.widget.CoordinatorLayout 
        ... 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content">//From match_parent to wrap_content, when the property is match_parent, it means that the view wants to be as big as its parent (minus padding) 
    

    しかし、これで私は引き出しの開閉ボタン(3つの水平線)を失いました。

    あなたのActionBarDrawerToggleには、ツールバーを渡さなかったため、引き出しの開閉ボタンがなくなっています。

    // NOTE: Make sure you pass in a valid toolbar reference. ActionBarDrawToggle() does not require it 
    // and will not render the hamburger icon without it. 
    var drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, Resource.String.drawer_open, Resource.String.drawer_close); 
    

    Here is my complete code about Drawerlayoutです。正常に動作します。

    +0

    ありがとう – xamDev

    関連する問題