Android 如何覆盖包含的工具栏布局的标题
我在覆盖包含布局的属性时遇到问题 我有一个基本工具栏布局,如下所示:Android 如何覆盖包含的工具栏布局的标题,android,android-layout,Android,Android Layout,我在覆盖包含布局的属性时遇到问题 我有一个基本工具栏布局,如下所示: <?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res/org.me" androi
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/org.me"
android:id="@+id/toolbar_homeview"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
android:background="@color/bright_foreground_material_dark"
android:elevation="4dp"
app:title="@string/homeview_title"
app:subtitle="@string/homeview_sub_title">
</android.support.v7.widget.Toolbar>
我在下面的布局中包含了上面的布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/org.me"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include
android:id="@+id/homeview_toolbar"
layout="@layout/homeview_toolbar_base"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
/>
``</LinearLayout>
``
我想覆盖app:title属性,但它就是不起作用。我犯了一个错误
为标记include找到意外的命名空间前缀app
这里可能有什么问题?用这个替换您的代码。我想让你简单的复制粘贴整个东西,以减少打字错误。如果你还有什么例外,请告诉我
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include
android:id="@+id/homeview_toolbar"
layout="@layout/homeview_toolbar_base"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" />
</LinearLayout>
xmlns:app=”http://schemas.android.com/apk/res-auto“
而不是xmlns:app=”http://schemas.android.com/apk/res/org.me"
我仍然会遇到同样的错误,你把它放在哪里了?我用…/res auto替换了…/res/org.me你需要在两个文件中都这样做。我按照你写的做了,但我仍然无法覆盖
标记中homeview\u工具栏内的应用程序:title
属性。这里有两个布局。你能提到这些xml的文件名吗?第一个是homeview\u toolbar\u base.xml
,它包含android:id=“@+id/toolbar\u homeview”
第二个是homeview\u toolbar.xml
,它包含标记
,其中包括homeview\u toolbar\u base.xml
,并试图覆盖问题所在的app:title。
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar android:id="@+id/toolbar_homeview"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/bright_foreground_material_dark"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:subtitle="@string/homeview_sub_title"
app:title="@string/homeview_title">
</android.support.v7.widget.Toolbar>