我从登录活动导航到设置活动,这是预期的行为:
但是当我运行模拟器时,会看到以下信息:
我的屏幕顶部不是蓝色,为什么?
这是我的 Activity.axml :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<include
android:id="@+id/settings_toolbar"
layout="@layout/layout_toolbar" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/settings_toolbar"
android:layout_centerInParent="true"
android:padding="@dimen/margin_medium">
<!-- Web Service Urls -->
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/webServiceUrl"
android:hint="@string/webServiceUrl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
app:MvxBind="Text WebServiceUrl"/>
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</RelativeLayout>
这是我的 layout_toolbar.axml :
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary">
<TextView
android:id="@+id/textview_toolbar_title"
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:textColor="@color/primaryTextColor" />
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
这是我的应用主题:
<!-- Base theme applied regardless of API level -->
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">@color/primaryColor</item>
<item name="colorPrimaryDark">@color/primaryDarkColor</item>
<item name="colorAccent">@color/accentColor</item>
<item name="colorControlNormal">@color/primaryColor</item>
<item name="colorControlActivated">@color/accentColor</item>
<item name="colorControlHighlight">@color/accentColor</item>
<item name="windowActionModeOverlay">false</item>
</style>
<!-- Default App theme applied if no resource style overrides for specific API level -->
<style name="AppTheme" parent="AppTheme.Base">
</style>
继续进行其他活动后,我还需要在工具栏中绘制箭头按钮,我该如何实现?
答案 0 :(得分:1)
您可以自定义工具栏并在工具栏中添加箭头图像
像这样
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="@color/white"
android:gravity="center"
android:minHeight="80dp"
app:contentInsetStartWithNavigation="0dp"
app:theme="@style/ToolbarStyle">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:textColor="@color/white"
android:textStyle="italic|bold" />
<ImageView
android:id="@+id/ivDashboard"
android:layout_width="140dp"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:paddingEnd="45dp"
android:paddingRight="45dp"
android:src="@drawable/app_logo"
tools:ignore="ContentDescription,RtlSymmetry" />
<ImageView
android:id="@+id/ivNotification"
android:layout_width="26dp"
android:layout_height="26dp"
android:layout_centerVertical="true"
android:layout_marginEnd="15dp"
android:layout_marginRight="15dp"
android:layout_toLeftOf="@+id/ivHelp"
android:src="@drawable/notifications_bell_button"
tools:ignore="ContentDescription" />
<ImageView
android:id="@+id/ivHelp"
android:layout_width="26dp"
android:layout_height="26dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginEnd="15dp"
android:layout_marginRight="15dp"
android:src="@drawable/info"
tools:ignore="ContentDescription" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>