<include android:id="@+id/cell1" layout="@layout/workspace_screen" />
参看
1、创建一个独立的布局文件作为共享布局,common_layout.xml
- view plaincopy to clipboardprint?
- <SPAN style="COLOR: #009900"><SPAN style="FONT-WEIGHT: bold; COLOR: #000000"><?xml</SPAN> <SPAN style="COLOR: #000066">version</SPAN>=<SPAN style="COLOR: #ff0000">"1.0"</SPAN> <SPAN style="COLOR: #000066">encoding</SPAN>=<SPAN style="COLOR: #ff0000">"utf-8"</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">?></SPAN></SPAN>
- <SPAN style="COLOR: #009900"><SPAN style="FONT-WEIGHT: bold; COLOR: #000000"><LinearLayout</SPAN></SPAN>
- <SPAN style="COLOR: #009900"> <SPAN style="COLOR: #000066">xmlns:android</SPAN>=<SPAN style="COLOR: #ff0000">"http://schemas.android.com/apk/res/android"</SPAN></SPAN>
- <SPAN style="COLOR: #009900"> <SPAN style="COLOR: #000066">android:layout_width</SPAN>=<SPAN style="COLOR: #ff0000">"wrap_content"</SPAN></SPAN>
- <SPAN style="COLOR: #009900"> <SPAN style="COLOR: #000066">android:layout_height</SPAN>=<SPAN style="COLOR: #ff0000">"wrap_content"</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">></SPAN></SPAN>
- <SPAN style="COLOR: #009900"><SPAN style="FONT-WEIGHT: bold; COLOR: #000000"><TextView</SPAN></SPAN>
- <SPAN style="COLOR: #009900"> <SPAN style="COLOR: #000066">android:layout_width</SPAN>=<SPAN style="COLOR: #ff0000">"wrap_content"</SPAN> </SPAN>
- <SPAN style="COLOR: #009900"> <SPAN style="COLOR: #000066">android:layout_height</SPAN>=<SPAN style="COLOR: #ff0000">"wrap_content"</SPAN> </SPAN>
- <SPAN style="COLOR: #009900"> <SPAN style="COLOR: #000066">android:text</SPAN>=<SPAN style="COLOR: #ff0000">"这是一个共享的布局文件"</SPAN></SPAN>
- <SPAN style="COLOR: #009900"> <SPAN style="FONT-WEIGHT: bold; COLOR: #000000">/></SPAN></SPAN>
- <SPAN style="COLOR: #009900"><SPAN style="FONT-WEIGHT: bold; COLOR: #000000"></LinearLayout<SPAN style="FONT-WEIGHT: bold; COLOR: #000000">></SPAN></SPAN></SPAN>
- view plaincopy to clipboardprint?
- <SPAN style="COLOR: #009900"><SPAN style="FONT-WEIGHT: bold; COLOR: #000000"></SPAN></SPAN>
- view plaincopy to clipboardprint?
- <SPAN style="COLOR: #009900"><SPAN style="FONT-WEIGHT: bold; COLOR: #000000"><SPAN style="FONT-WEIGHT: bold; COLOR: #000000"><P>2、在主布局中使用标签进行包含</P><PRE class=xml style="FONT-FAMILY: monospace" name="code"><SPAN style="COLOR: #009900"><SPAN style="FONT-WEIGHT: bold; COLOR: #000000"><?xml</SPAN> <SPAN style="COLOR: #000066">version</SPAN>=<SPAN style="COLOR: #ff0000">"1.0"</SPAN> <SPAN style="COLOR: #000066">encoding</SPAN>=<SPAN style="COLOR: #ff0000">"utf-8"</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">?></SPAN></SPAN>
- <SPAN style="COLOR: #009900"><SPAN style="FONT-WEIGHT: bold; COLOR: #000000"><LinearLayout</SPAN> <SPAN style="COLOR: #000066">xmlns:android</SPAN>=<SPAN style="COLOR: #ff0000">"http://schemas.android.com/apk/res/android"</SPAN></SPAN>
- <SPAN style="COLOR: #009900"> <SPAN style="COLOR: #000066">android:orientation</SPAN>=<SPAN style="COLOR: #ff0000">"vertical"</SPAN></SPAN>
- <SPAN style="COLOR: #009900"> <SPAN style="COLOR: #000066">android:layout_width</SPAN>=<SPAN style="COLOR: #ff0000">"fill_parent"</SPAN></SPAN>
- <SPAN style="COLOR: #009900"> <SPAN style="COLOR: #000066">android:layout_height</SPAN>=<SPAN style="COLOR: #ff0000">"fill_parent"</SPAN></SPAN>
- <SPAN style="COLOR: #009900"> <SPAN style="FONT-WEIGHT: bold; COLOR: #000000">></SPAN></SPAN>
- <SPAN style="COLOR: #009900"><SPAN style="FONT-WEIGHT: bold; COLOR: #000000"><include</SPAN> <SPAN style="COLOR: #000066">layout</SPAN>=<SPAN style="COLOR: #ff0000">"@layout/common_layout"</SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000">></SPAN><SPAN style="FONT-WEIGHT: bold; COLOR: #000000"></include<SPAN style="FONT-WEIGHT: bold; COLOR: #000000">></SPAN></SPAN></SPAN>
- <SPAN style="COLOR: #009900"><SPAN style="FONT-WEIGHT: bold; COLOR: #000000"></LinearLayout<SPAN style="FONT-WEIGHT: bold; COLOR: #000000">></SPAN></SPAN></SPAN></PRE>
- <PRE class=xml style="FONT-FAMILY: monospace" name="code"><SPAN style="COLOR: #009900"><SPAN style="FONT-WEIGHT: bold; COLOR: #000000"></SPAN></SPAN></PRE>
- <PRE class=xml style="FONT-FAMILY: monospace" name="code"><SPAN style="COLOR: #009900"><SPAN style="FONT-WEIGHT: bold; COLOR: #000000"></SPAN></SPAN></PRE>
- </SPAN></SPAN></SPAN>