如何嵌入里面的另一个布局在我的情况?我的、布局、里面、情况

2023-09-05 08:26:23 作者:竹筏

如果我有一个名为布局的的 bottom.xml 的

If I have a layout called bottom.xml,

bottom.xml:的(只包含一个TextView和编辑文本视图)

bottom.xml:(simply contain a textview and edit text view)

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:orientation="vertical"
     >
        <TextView 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:gravity="center_horizontal" 
            android:text="@string/username"

        />

        <EditText 
            android:id="@+id/name"

            android:layout_width="120dip"
            android:layout_height="50dip"
            android:layout_gravity="center_horizontal"     
        />
 </LinearLayout>

有没有办法为嵌入上面的的 bottom.xml 的里面的其他布局,而不是反复编写相同的code布局一些布局文件(当其他的布局有一个包含相同的布局bottom.xml的一部分)?

Is there any way to embed the above bottom.xml layout inside other layouts instead of repeatly writing the same code in several layout files (when other layouts have a part which contains the same layout as bottom.xml)?

例如,如果我的的 admin.xml的的的布局中也含有它看起来完全一样的的 bottom.xml ,如何只嵌入 bottom.xml 内部> admin.xml的的>

 
精彩推荐