Android 包括不工作
我尝试将此设置为我的活动布局:Android 包括不工作,android,android-layout,include,Android,Android Layout,Include,我尝试将此设置为我的活动布局: <?xml version="1.0" encoding="utf-8"?> <include layout="@layout/map_activity_base" /> 因此,android似乎认为应该是一个视图,但这只有在我使用而没有任何周围视图的情况下才会发生 那么,是否可以在没有任何周围环境的情况下使用查看呢?如果没有,实现我想要的最好方法是什么 顺便说一句:我不知道这是否重要,但这是图书馆项目的内容 编辑:map\u activ
<?xml version="1.0" encoding="utf-8"?>
<include layout="@layout/map_activity_base" />
因此,android似乎认为
应该是一个视图
,但这只有在我使用
而没有任何周围视图的情况下才会发生
那么,是否可以在没有任何周围环境的情况下使用
查看呢?如果没有,实现我想要的最好方法是什么
顺便说一句:我不知道这是否重要,但这是图书馆项目的内容
编辑:map\u activity\u base.xml
<?xml version="1.0" encoding="UTF-8" ?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapContainer"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView android:id="@+id/listHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:gravity="center"
android:text="@string/listHeader"
android:padding="5dp" />
<View android:id="@+id/divider"
android:layout_width="100dp"
android:layout_height="1dp"
android:background="#333"
android:layout_below="@id/listHeader" />
<de.l_one.app.map.base.POIListView android:id="@+id/poiList"
android:layout_width="100sp"
android:layout_height="match_parent"
android:divider="#cccccc"
android:dividerHeight="1dp"
android:layout_alignParentLeft="true"
android:layout_below="@id/divider"
android:listSelector="@android:color/transparent" />
<com.google.android.maps.MapView
android:id="@+id/mapview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toRightOf="@id/poiList"
android:clickable="true"
android:apiKey="@string/googleAPIKey" />
<TextView android:id="@+id/cmtryNameTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:padding="5dp"
android:background="@drawable/cmtry_txt_view_back" />
<TextView android:id="@+id/navigate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@id/cmtryNameTextView"
android:padding="5dp"
android:background="@drawable/cmtry_txt_view_back"
android:visibility="gone"
android:text="@string/navigate" />
</RelativeLayout>
我认为您至少需要在根视图中添加“include”。大致如下:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
...
<include layout="@layout/titlebar"/>
...
看起来无法在布局的根位置定义
。如果确实需要从包含开始,更好的方法是使用
:
文件fragment_map.xml
<?xml version="1.0" encoding="utf-8"?>
<!--
the <merge/> tag must be the root element
while it actually defines an xml include.
-->
<merge
xmlns:android="http://schemas.android.com/apk/res/android">
<!-- insert some layout here -->
</merge>
文件activity_map.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- then the <include/> tag can then reference it, while merging. -->
<include
layout="@layout/fragment_map"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</android.support.design.widget.CoordinatorLayout>
更新了一点xml/注释,因为我很挣扎(合并工作就是这样)。
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- then the <include/> tag can then reference it, while merging. -->
<include
layout="@layout/fragment_map"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</android.support.design.widget.CoordinatorLayout>