![](/img/trans.png)
[英]How to add views dynamically to a RelativeLayout already declared in the xml layout?
[英]how to use views declared in one layout xml file in other layout
尊敬的所有人,我正在研究android技術。 我使用了在另一種布局中聲明的地圖視圖。我必須在五月屏幕的某些部分中顯示。 我可以使用相同的地圖視圖,還是必須以編程方式創建新的地圖視圖? 簡而言之,我必須在屏幕的某些部分顯示地圖。 我該怎么辦..謝謝(維克拉姆·卡丹)
您需要使用標簽<include>
。 從Google文檔中:
<com.android.launcher.Workspace
android:id="@+id/workspace"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
launcher:defaultScreen="1">
<include android:id="@+id/cell1" layout="@layout/workspace_screen" />
<include android:id="@+id/cell2" layout="@layout/workspace_screen" />
<include android:id="@+id/cell3" layout="@layout/workspace_screen" />
</com.android.launcher.Workspace>
我將在XML文件中定義視圖,然后每次需要時,都可以從XML文件中擴展視圖。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.