2015-04-23 68 views
0

在下面的布局appcompat 22.1.0中的android:主题仅适用于工具栏吗?

<LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark"> 

     <TextView 
      android:id="@+id/name" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 
    </LinearLayout> 

TextView没有使用上-L预先设备主题的文本的颜色。如果我将这个主题声明移动到TextView,它适用于所有设备。克里斯·巴内斯在他的文章中写道:

在22.1.0我们现在已经扩大了功能,以便您可以设置 一个主题在你的布局任何看法。 https://chris.banes.me/2015/04/22/support-libraries-v22-1-0/

所以我很困惑,错误?

编辑

我看着工具栏和工具栏似乎也有这个问题,下面的布局没有工作打算过:

<android.support.v7.widget.Toolbar 
    android:id="@+id/toolbar" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="?attr/colorPrimary" 
    android:minHeight="?attr/actionBarSize" 
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

    <TextView 
     android:layout_width="wrap_content" 
     android:text="#@#@SDAG" 
     android:layout_height="wrap_content" /> 
</android.support.v7.widget.Toolbar> 
+0

将该文章链接到此处。 –

+0

我已将其链接添加到文章 – Mikooos

+0

也许在此处发布您的主题以展示如何设置它。 – Sharj

回答

0

我找到来源。我直接将项目添加到R.id.content。像LayoutInflater.from(this).inflate(R.layout.my_activity, findViewById(R.id.content);,而不是使用setContentView方法,做所有的魔术东西。不幸的是,在文档中没有必要使用setContentXXX方法。

相关问题