Xamarin Bottom Bar迷失了

时间:2016-10-16 17:10:53

标签: xamarin

我有一个列表视图,一个工具栏和一个底部导航栏。工具栏与顶部对齐,而导航栏与底部对齐。除非我将项目添加到listview,否则它运行良好。添加5个项目后,底栏消失。我不能像工具栏那样对齐机器人吧,它只是保持静止?

活动的斧头

<?xml version="1.0" encoding="utf-8"?>

  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
  <include
   android:id="@+id/toolbar"
   layout="@layout/toolbar" />

  <ListView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/listv_sepet" />
     <include
   android:id="@+id/toolbar_bottom"
   layout="@layout/toolbar_bot"
   android:layout_alignParentBottom="true"/>     

 </LinearLayout>
  </RelativeLayout>

Bottom Toolbar axml

<?xml version="1.0" encoding="utf-8"?>
   <android.support.v7.widget.Toolbar                               xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar_bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
/>

先谢谢你。

2 个答案:

答案 0 :(得分:0)

问题是你包装了ListView的高度,并且不要告诉它在底部工具栏的上方。

这可以通过以下方式轻松解决:

  1. 取消嵌套布局,因为在这种情况下不需要进行任何嵌套。
  2. 告诉ListView位于顶部工具栏下方和底部工具栏上方
  3. 这样的事情:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <include
            android:id="@+id/toolbar"
            android:layout_alignParentTop="true"
            layout="@layout/toolbar" />
    
        <ListView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@+id/toolbar" 
            android:layout_above="@+id/toolbar_bottom"
            android:id="@+id/listv_sepet" />
    
        <include
            android:id="@+id/toolbar_bottom"
            layout="@layout/toolbar_bot"
            android:layout_alignParentBottom="true"/>     
    </RelativeLayout>
    

    那应该解决它。

答案 1 :(得分:-1)

使用AddHeaderViewAddFooterView方法绑定到列表视图时,您可以在代码中设置包含页脚(和标题),而不是在布局中使用包含

例如:

        listView = view.FindViewById<ListView>(Resource.Id.mylistView);
        View headerView = View.Inflate(Activity, Resource.Layout.ListHeader, null);
        listView.AddHeaderView(headerView);