2015-04-23 70 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方法。

相關問題