Android: How to use tools with include layout Android: How to use tools with include layout xml xml

Android: How to use tools with include layout


Check this link, Android tools attributes. It should give you an idea as to how to use the tools attributes.Specifically look at the tools:showIn attribute. It basically allows you to render layout_A in layout_B, in which layout_B has <include layout="@layout/layout_A"/> somewhere in the xml.

Here's an example:

layout_A

<?xml version="1.0" encoding="utf-8"?><RelativeLayout 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"    tools:showIn="@layout/layout_B"    ><!-- Your layout code goes here --></RelativeLayout>

layout_B

<?xml version="1.0" encoding="utf-8"?><RelativeLayout 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"    ><include layout="@layout/layout_A"/><!-- Your layout code goes here --></RelativeLayout>


add layout_width and layout_height to the include tag , otherwise you will find it difficult to arrange it in an RelativeLayout