首页 > 解决方案 > 自定义工具栏未出现在预览选项卡中

问题描述

这是一个非常奇怪的问题,我在很长一段时间内都面临着。通过添加“Base”,我能够解决阻止任何类型的小部件未出现在活动预览选项卡中的问题。到主题。如果我在我的设备上测试它,我可以看到我的自定义工具栏,但在 Android Studio 的预览选项卡中,它都显示为白色。我试过的:

1- 重新启动 Android Studio 2- 无效缓存并重新启动 Android Studio 3- 将应用主题更改为不同

在此处输入图像描述

工具栏.xml

<android.support.v7.widget.Toolbar 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="100dp"
android:background="#263238"
android:elevation="8dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

<TextView
    android:id="@+id/refToolbarTitleID"
    style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="start" />

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="TEST TEXT" />


</RelativeLayout>

我无法正确设置我的工具栏。任何帮助表示赞赏,谢谢!

标签: androidtoolbar

解决方案


您忘记</android.support.v7.widget.Toolbar>在 XML 末尾添加。


推荐阅读