Note that there are some explanatory texts on larger screens.

plurals
  1. POOnly some Layout Params work
    primarykey
    data
    text
    <p>I am trying to align a custom View object above and aligned_left of a RelativeLayout. My (snipped) code looks something like this: </p> <pre><code>int bored = board.getId(); //board is the RelativeLayout Border border = new Border(); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_LEFT, bored); params.addRule(RelativeLayout.ABOVE, bored); this.addView(border,params); </code></pre> <p>This gives me a Border object aligned_left with my RelativeLayout but NOT "ABOVE" (technically, it is above it, but it's at the top of the screen not aligned the way it's supposed to be). And, even stranger, when I do this: </p> <pre><code>int bored = board.getId(); Border border = new Border(); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_LEFT, bored); params.addRule(RelativeLayout.BELOW, bored); //&lt;---The only difference this.addView(border,params); </code></pre> <p>...it works perfectly. it is aligned left and below in the ways that are expected. Why is the ABOVE attribute giving me such a hard time?</p> <p>Edit:<br> ABOVE is supposed to align the bottom edge of one view with the top edge of the target. Here is a screen shot of how my project is not working as intended.<br> <img src="https://i.stack.imgur.com/3Fw26.png" alt="enter image description here"> </p> <p>The green bar at the top of the screen is the Border object I am trying to align. As you can see, its left edge is aligned with "board" however it is in the wrong place at the top of the screen.</p>
    singulars
    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