1

I want to define the following xml once, and then reuse it any activity. I just read that I can use styles, but the examples here only style a single View with no children. I know I can inflate this, but is it possible to do this purely in xml?

<RelativeLayout
android:id="@+id/group_chat_form"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginTop="5dp"
android:background="@drawable/transparent_background2" >

    <TextView 
    android:id="@+id/send_msg_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:background="@drawable/transparent_background2"
    android:text="Send" />

    <EditText
    android:id="@+id/group_chat_input_box"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignTop="@id/send_msg_button"
    android:layout_toLeftOf="@id/send_msg_button"
    android:background="#00000000"
    android:hint="@string/type_a_message"
    android:textColorHint="#EEEEEE"
    android:inputType="textMultiLine"
    android:maxLines="5"
    android:paddingLeft="5dp"
    android:paddingRight="5dp"
    android:paddingTop="4dp"
    android:paddingBottom="4dp"
    android:textColor="#FFFFFF"
    android:textSize="20sp"
    android:shadowColor="#000000"
    android:shadowRadius="3"
    android:shadowDx="3"
    android:shadowDy="3"/> 

</RelativeLayout>
Kacy
  • 3,330
  • 4
  • 29
  • 57

1 Answers1

3

use include tag. See this guide.

EDIT

Also see this answer

Community
  • 1
  • 1
Sushant
  • 1,834
  • 19
  • 32
  • That works for the specific example I gave, but I would like to know how to do this if the outermost view wasn't a layout. Gave you an upvote for now. – Kacy Mar 07 '15 at 16:33
  • I think you are trying to refer to `merge` tag. is also explained in above link – Sushant Mar 07 '15 at 16:37