Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/207.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
appcompat 22.1.0中的android:theme是否仅适用于工具栏?_Android_Android Appcompat - Fatal编程技术网

appcompat 22.1.0中的android:theme是否仅适用于工具栏?

appcompat 22.1.0中的android:theme是否仅适用于工具栏?,android,android-appcompat,Android,Android Appcompat,在下面的布局中 <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/ThemeOverlay.AppCompat.Dark"> <TextView android:id="@+id/name"

在下面的布局中

    <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>
使用新版本(v22.1)的support lib,您的活动应该扩展
AppCompatActivity
,而不是以前扩展的
ActionBarActivity


以下是谷歌开发者的帖子:

我找到了问题的根源。我直接将项目添加到R.id.content。像
LayoutInflater.from(this).充气(R.layout.my_活动,findViewById(R.id.content);
而不是使用
setContentView
方法来完成所有神奇的事情。不幸的是,在文档中没有一个词要求你必须使用
setContentXXX
方法。

在这里链接那篇文章。我已经将它添加到文章的链接可能会在这里发布你的主题,以展示你是如何设置的。为什么这会很重要?我使用light app compat with custom颜色,仅此而已。它应该这样做,我也应该这样做,尽管这并不重要,因为不推荐的一个扩展了有效的一个。
<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>