Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Gridlayout: Add new views always on high-water-mark
    primarykey
    data
    text
    <p>I am trying to use GridLayout (not GridView!) to achieve a layout like this:</p> <p><img src="https://i.stack.imgur.com/GWwEk.png" alt="enter image description here"></p> <p>But with my code (and everything I tried until now) the top of two horizontally adjacent views are always aligned. Is it possible to tell the each new View to be aligned on the high-water-mark of its column instead? (see <a href="http://android-developers.blogspot.co.at/2011/11/new-layout-widgets-space-and-gridlayout.html" rel="nofollow noreferrer">New Layout Widgets: Space and GridLayout</a> under "Automatic Index Allocation")</p> <p>My layout.xml looks like this right now:</p> <pre><code>&lt;GridLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/scroll_view_container" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" android:columnCount="2" /&gt; </code></pre> <p>To this GridLayout I add my Views programmatically:</p> <pre><code>GridLayout scrollViewContainer = Views.findById(rootView, R.id.scroll_view_container); for (i=0; i &lt; list.size(); i++) TextView tv = new TextView(context); tv.setText("foobar"); GridLayout.LayoutParams lp = new GridLayout.LayoutParams(); // left, right, left, right - creates new default rows lp.columnSpec = GridLayout.spec(i%2); // this would put every view in the same row =&gt; all Views are on the very top // lp.rowSpec = GridLayout.spec(0); tv.setLayoutParams(lp); scrollViewContainer.addView(tv); } </code></pre>
    singulars
    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.
    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