appcompat 22.1.0中的android:主题仅适用于工具栏吗?
在下面的布局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>
我找到来源。我直接将项目添加到R.id.content。像LayoutInflater.from(this).inflate(R.layout.my_activity, findViewById(R.id.content);
,而不是使用setContentView
方法,做所有的魔术东西。不幸的是,在文档中没有必要使用setContentXXX
方法。
随着新版本(v22.1 )的支持lib您的活动应扩展到AppCompatActivity
而不是您以前用于扩展的ActionBarActivity
。
下面是谷歌开发者后:问题的http://android-developers.blogspot.com/2015/04/android-support-library-221.html
它应该和我这样做,但不要紧,因为已弃用的扩展了有效的扩展。 – Mikooos
将该文章链接到此处。 –
我已将其链接添加到文章 – Mikooos
也许在此处发布您的主题以展示如何设置它。 – Sharj