简体   繁体   中英

Custom toolbar not appearing in preview tab

this is a very weird problem that I am facing for quite a lot of time. I was able to fix an issue which prevented any sort of widgets not appearing in an activity preview tab by adding "Base." to the theme. If I test it on my device, I can see my custom toolbar but in Android studio`s preview tab it all appears white. What I have tried:

1- Restarted Android studio 2- Invalidated caches and restarted Android studio 3- Changing app theme to different

在此处输入图片说明

toolbar.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>

I can not properly setup my toolbar. Any help is appreciated, thanks!

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

我认为您以错误的方式使用工具栏,必须将工具栏放在根布局中,就像使用按钮或文本视图一样,然后将其固定在屏幕的顶部。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM