Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I actually accomplished this today through a little bit of experimentation based upon what Tim said. I moved away from "onMeasure()" and only wrote this code for it:</p> <pre><code>@Override public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // Call the super class. super.onMeasure(widthMeasureSpec, heightMeasureSpec); // Set the dimensions of this view. this.setMeasuredDimension((int) width, (int) width); } </code></pre> <p>Width is a global float. Where does width come from? I derived width from this method that I wrote in the view to resize:</p> <pre><code>public void initSize(float size) { width = size; this.invalidate(); } </code></pre> <p>I call "invalidate()" to redraw the view. Something has to call this method though, so I do so in the activity. First, I get the size of the screen in the Activity, not the View, using this code:</p> <pre><code>Display thisDisplay = this.getWindowManager().getDefaultDisplay(); Point desiredSize = new Point(); display.getSize(desiredSize); int width = size.x; </code></pre> <p>You used to be able to call a method called "getWidth()" on "thisDisplay" but this method is now depreciated, so you should use "getSize()" instead. Finally, right after you initialize the constructor, call the "initSize()" method:</p> <pre><code>nameBox = (InfoBoxView) findViewById(R.id.nameBox); nameBox.initSize(width); </code></pre> <p>Now, all the views will be the same size. I don't know if this is the <em>best</em> way to do this, but it works for now and I figured I'd post it here so everyone knew. :)</p>
    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.
 

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