【发布时间】:2017-08-26 21:32:04
【问题描述】:
我想将我的应用程序字体与操作栏的字体相匹配。我需要知道操作栏上使用的字体和样式。我也想要同样的颜色。提供了我的意思的代码示例和图片。
在上图中,我想将“GPATrack”的文字与“Menu”的文字相匹配。我还想让“菜单”的背景与操作栏的颜色相同。
这是控制上图中视图的 XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="80dp"
android:background="@drawable/side_nav_bar"
android:gravity="top"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/nav_header_vertical_spacing"
android:text="@string/menu"
android:gravity="center_horizontal"
android:textSize="24dp"
android:textColor="#fffeff" />
</LinearLayout>
这只是一个例子,不是我的实际应用程序,我删除了所有看起来会增加混乱的东西。
【问题讨论】:
-
"我还想让“菜单”的背景与操作栏的颜色相同" -- 你是选择操作栏颜色的人。它在你的主题中。看看你在那里选择了什么,然后使用相同的颜色。
-
@CommonsWare 颜色是 android studio 在创建项目时选择的。因此,我什至不知道那在哪里。我感觉它是默认的,这意味着它甚至没有在任何地方列出。如果它也是默认字体样式,我怎么知道?
-
"颜色是android studio在创建项目时选择的" -- 然后选择你自己的颜色,所以你控制值。在您的主题中使用它,并将其用于您的其他 UI 元素。 “如果它也是默认的,我怎么知道字体样式?” ——没有单一的“默认”。它因主题而异(
Theme.Holo、Theme.Material、Theme.AppCompat等)。
标签: android android-layout fonts android-actionbar