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>