Note that there are some explanatory texts on larger screens.

plurals
  1. POsetting layout attribute for include
    primarykey
    data
    text
    <p>In my Android app I declare a custom view in a separate XML file.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout android:id="@+id/download_interval_setter" android:layout_width="wrap_content" android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical"&gt; &lt;Button android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/Button_interval_up" style="?android:attr/buttonStyleSmall"&gt; &lt;/Button&gt; &lt;EditText android:id="@+id/Download_interval" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="1" android:numeric="integer"&gt; &lt;/EditText&gt; &lt;Button android:id="@+id/Button_interval_down" style="?android:attr/buttonStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" &gt; &lt;/Button&gt; &lt;/LinearLayout&gt; </code></pre> <p>Then I have my main.xml file where I would like to include the view declared in above XML like this:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;ToggleButton android:layout_height="wrap_content" android:id="@+id/XMLStart" android:textOn="@string/auto_update_on" android:textOff="@string/auto_update_off" android:layout_width="wrap_content" /&gt; &lt;include layout="@layout/download_interval_setter" android:layout_toRightOf="@id/XMLStart"/&gt; &lt;Button android:layout_height="wrap_content" android:id="@+id/ShowRadars" android:text="@string/show_radars" android:layout_width="wrap_content" android:layout_below="@id/XMLStart"/&gt; &lt;Button android:layout_height="wrap_content" android:id="@+id/ShowAccidents" android:text="@string/show_accidents" android:layout_width="wrap_content" android:layout_toRightOf="@id/ShowRadars" android:layout_below="@id/XMLStart"/&gt; &lt;Button android:layout_height="wrap_content" android:id="@+id/ShowConstraints" android:text="@string/show_constraints" android:layout_width="wrap_content" android:layout_below="@id/ShowRadars"/&gt; &lt;Button android:layout_height="wrap_content" android:id="@+id/ShowPatrols" android:text="@string/show_patrols" android:layout_width="wrap_content" android:layout_below="@id/ShowRadars" android:layout_toRightOf="@id/ShowConstraints"/&gt; &lt;/RelativeLayout&gt; </code></pre> <p>As you can see I am trying to set the layout_toRightOf attribute of the included view but it is not set, as I can see also in hierarchyviewer</p> <p>On the other hand if I simply copy-paste the content of the download_interval_setter.xml file to main.xml and declare the layout_toRightOf parameter there , the view will be positioned to right of as I want.</p> <p>Where am I going wrong? Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload