title: How to hide partially visible views in Android layout xml without code?
body: <p><strong>Please read the question fully before answering!</strong></p>
  
  <p>Suppose I have two views:</p>
  
  <ol>
  <li><code>first</code> (yellow) in the bottom</li>
  <li><code>second</code> (cyan) filling the rest of the view above <code>first</code></li>
  </ol>
  
  <p><em>The size of the parent view is dynamic.</em></p>
  
  <p><strong>How can I achieve the below Expected column UI when the parent height is dynamically set to the values in the first column?</strong> Notice how the partially visible view is just hidden instead of cropped.</p>
  
  <p><img src="https://i.stack.imgur.com/QVPey.png" alt="What I want to achieve"></p>
  
  <h1>Constraints</h1>
  
  <ul>
  <li>Any <strong>code is not a possibility</strong>, I know it's possible to solve the problem with:
  <code>second.setVisibility(second.getHeight() &lt; SECONDS_PREFERRED_SIZE? GONE : VISIBLE)</code>
  but I don't have access to <code>getHeight()</code> so the solution must be bare xml.<br>
  It can be relaxed to code only writing UI state via <code>RemoteViews</code>.</li>
  <li>Based on the above <strong>no custom views</strong> are allowed, <strong>no</strong>t even <strong>libraries</strong>, just <strong>basic layout managers</strong>:<br>
  <code>FrameLayout</code>, <code>LinearLayout</code>, <code>RelativeLayout</code>, <code>GridLayout</code><br>
  or as a last resort one of the advanced ones:<br>
  <code>ViewFlipper</code>, <code>ListView</code>, <code>GridView</code>, <code>StackView</code> or <code>AdapterViewFlipper</code></li>
  <li>The <code>layout_width</code> and <code>layout_height</code> is <strong>dynamic</strong><br>
  In the example I fixed it so it's easy to try out different variations. The above image is the <code>layout_height</code> changed to the displayed value simulating the possibilities I want to handle.</li>
  <li>I used <code>TextView</code>, but it should be generally applicable to any <code>View</code></li>
  <li>Observant people may have noticed that the above constrains the solution to <a href="http://developer.android.com/guide/topics/appwidgets/index.html#CreatingLayout" rel="noreferrer">Home screen <strong>app widgets</strong> with <code>RemoteViews</code></a>.</li>
  </ul>
  
  <h1>Tries</h1>
  
  <p>I tried implementing with <code>RelativeLayout</code> and <code>LinearLayout</code>, but they both behave as the Actual column on the picture.</p>
  
  <h2>RelativeLayout</h2>
  
  <pre><code>&lt;RelativeLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="64dp" (actually fill_parent, but fix it for sake of simplicity)
      android:layout_height="fill_parent" (first column on picture)
      android:layout_gravity="center"
      android:background="#666"
      tools:ignore="HardcodedText,RtlHardcoded"
      &gt;
      &lt;TextView
          android:id="@+id/first"
          android:layout_width="wrap_content"
          android:layout_height="16dp"
          android:layout_alignParentBottom="true"
          android:layout_alignParentRight="true"
          android:background="#8ff0"
          android:text="First"
          /&gt;
      &lt;TextView
          android:id="@+id/second"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:layout_above="@id/first"
          android:background="#80ff"
          android:text="Second"
          android:gravity="center"
          /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <h2>LinearLayout</h2>
  
  <pre><code>&lt;LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="64dp" (actually fill_parent, but fix it for sake of simplicity)
      android:layout_height="fill_parent" (first column on picture)
      android:layout_gravity="center"
      android:background="#666"
      android:orientation="vertical"
      tools:ignore="HardcodedText,RtlHardcoded"
      &gt;
      &lt;TextView
          android:id="@+id/second"
          android:layout_width="fill_parent"
          android:layout_height="0dp"
          android:layout_weight="1"
          android:background="#80ff"
          android:text="Second"
          android:gravity="center"
          /&gt;
      &lt;TextView
          android:id="@+id/first"
          android:layout_width="wrap_content"
          android:layout_height="16dp"
          android:layout_gravity="right"
          android:background="#8ff0"
          android:text="First"
          /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>