获取 xamarin 屏幕底部的自定义工具栏 android
Getting a custom toolbar to the bottom of the screen for xamarin android
我有一个正在开发的应用程序,并且创建了两个自定义工具栏。最上面的那个正确地位于屏幕的顶部,但是如果你看下面的屏幕截图,我需要屏幕最底部的底部黑色工具栏....
下面是我的 axml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:orientation="vertical"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:gravity="center_vertical|center_horizontal">
<include
android:id="@+id/toolbar"
layout="@layout/starttoolbar" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true"
android:orientation="vertical"
android:layout_below="@id/toolbar">
<TextView
android:id="@+id/SignInView"
android:layout_centerHorizontal="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_marginTop="15dp"
android:layout_marginBottom="10dp"
android:textSize="30dp"
android:background="#d3d3d3"
android:text=" Sign in below" />
<TextView
android:id="@+id/BlankView"
android:layout_centerHorizontal="true"
android:layout_width="fill_parent"
android:layout_height="5dp"
android:textSize="30dp" />
<TextView
android:id="@+id/CustTextView"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_marginBottom="10dp"
android:textSize="20dp"
android:text=" Customer" />
<EditText
android:layout_width="fill_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:id="@+id/UserName"
android:text="UserName"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:layout_marginTop="15dp"
android:layout_marginBottom="12dp" />
<EditText
android:layout_width="fill_parent"
android:id="@+id/Password"
android:text="Password"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:layout_marginLeft="5dp"
android:gravity="center"
android:layout_marginTop="12dp"
android:layout_marginBottom="12dp" />
<Button
android:id="@+id/LoginButton"
android:layout_width="fill_parent"
android:layout_marginTop="20dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="12dp"
android:background="@drawable/GreenButton"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="@string/Login"
style="@style/button_text" />
<include
android:id="@+id/bottomtoolbar"
layout="@layout/toolbarbottom"
android:gravity="bottom" />
</LinearLayout>
</RelativeLayout>
底部工具栏是我一直需要的东西。
下面是底部工具栏自定义工具栏的代码
<?xml version="1.0" encoding="utf-8"?>
<Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar_bottom"
android:minHeight="?android:attr/actionBarSize"
android:background="#000000"
android:theme="@android:style/ThemeOverlay.Material.Dark.ActionBar"
android:popupTheme="@android:style/ThemeOverlay.Material.Light"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageButton
android:id="@+id/HelpButton"
android:layout_width="wrap_content"
android:background="@drawable/RedButton"
android:gravity="left"
android:layout_height="wrap_content"
android:src="@drawable/back48x58"
style="@style/back_button_text" />
</Toolbar>
所以我找到了使用 layout_weight 并插入 space 的解决方案。所以 space 的权重为 1,底部标题栏的权重为 0。这解决了代码的问题:
<Space
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/space2"
android:layout_marginBottom="5dp"
android:layout_weight="1" />
<include
android:id="@+id/bottomtoolbar"
layout="@layout/toolbarbottom"
android:layout_weight="0" />
我有一个正在开发的应用程序,并且创建了两个自定义工具栏。最上面的那个正确地位于屏幕的顶部,但是如果你看下面的屏幕截图,我需要屏幕最底部的底部黑色工具栏....
下面是我的 axml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:orientation="vertical"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:gravity="center_vertical|center_horizontal">
<include
android:id="@+id/toolbar"
layout="@layout/starttoolbar" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true"
android:orientation="vertical"
android:layout_below="@id/toolbar">
<TextView
android:id="@+id/SignInView"
android:layout_centerHorizontal="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_marginTop="15dp"
android:layout_marginBottom="10dp"
android:textSize="30dp"
android:background="#d3d3d3"
android:text=" Sign in below" />
<TextView
android:id="@+id/BlankView"
android:layout_centerHorizontal="true"
android:layout_width="fill_parent"
android:layout_height="5dp"
android:textSize="30dp" />
<TextView
android:id="@+id/CustTextView"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_marginBottom="10dp"
android:textSize="20dp"
android:text=" Customer" />
<EditText
android:layout_width="fill_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:id="@+id/UserName"
android:text="UserName"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:layout_marginTop="15dp"
android:layout_marginBottom="12dp" />
<EditText
android:layout_width="fill_parent"
android:id="@+id/Password"
android:text="Password"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:layout_marginLeft="5dp"
android:gravity="center"
android:layout_marginTop="12dp"
android:layout_marginBottom="12dp" />
<Button
android:id="@+id/LoginButton"
android:layout_width="fill_parent"
android:layout_marginTop="20dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="12dp"
android:background="@drawable/GreenButton"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="@string/Login"
style="@style/button_text" />
<include
android:id="@+id/bottomtoolbar"
layout="@layout/toolbarbottom"
android:gravity="bottom" />
</LinearLayout>
</RelativeLayout>
底部工具栏是我一直需要的东西。
下面是底部工具栏自定义工具栏的代码
<?xml version="1.0" encoding="utf-8"?>
<Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar_bottom"
android:minHeight="?android:attr/actionBarSize"
android:background="#000000"
android:theme="@android:style/ThemeOverlay.Material.Dark.ActionBar"
android:popupTheme="@android:style/ThemeOverlay.Material.Light"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageButton
android:id="@+id/HelpButton"
android:layout_width="wrap_content"
android:background="@drawable/RedButton"
android:gravity="left"
android:layout_height="wrap_content"
android:src="@drawable/back48x58"
style="@style/back_button_text" />
</Toolbar>
所以我找到了使用 layout_weight 并插入 space 的解决方案。所以 space 的权重为 1,底部标题栏的权重为 0。这解决了代码的问题:
<Space
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/space2"
android:layout_marginBottom="5dp"
android:layout_weight="1" />
<include
android:id="@+id/bottomtoolbar"
layout="@layout/toolbarbottom"
android:layout_weight="0" />