我正在测试材料设计,并且正在使用扩展工具栏开发应用程序。我的应用程序非常简单:主要活动扩展ActionBarActivity
,我的布局如下所示:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".WeatherActivity"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/my_toolbar"
android:layout_height="128dp"
popupTheme="@style/ActionBarPopupThemeOverlay"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@android:color/white"
android:text="@string/location_placeholder"
android:textAlignment="viewStart"
android:layout_gravity="start"
/>
</LinearLayout>
现在我想将当前位置显示为标题。我注意到的第一件事是在我的 Android Emulator (API 18) 中,标题似乎不遵守关于左边距下边距的材料指南,它出现在左侧并垂直输入到工具栏内。那么我应该使用工具栏标题(toolbar.setTitle)还是其他东西?其次,如果我想创建更复杂的内容,例如标题和简短描述(如布局结构中的材料指南所示),我的布局应该是什么?感谢您的支持!