Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'd recommend using directories that define font size for both the portrait and landscape orientation. For example:</p> <pre><code>values/dimen.xml values-land/dimen.xml </code></pre> <p>In each of the dimen.xml files, you would have the font size defined for your buttons.</p> <pre><code>values/dimen.xml: &lt;dimen name="button_fontSize"&gt;12sp&lt;/dimen&gt; values-land/dimen.xml &lt;dimen name="button_fontSize"&gt;24sp&lt;/dimen&gt; </code></pre> <p>When an activity is launched or the device is rotated, your xml layout will grab the font size appropriate for the current orientation.</p> <p><strong>Edit:</strong> In response to your use of <code>android:configChanges</code> to capture the calculator display, I'd like to offer an alternative that should be easier to implement and simplify coding.</p> <p>In the example below, I am assuming your calc screen consists of a <code>TextView</code> named <code>calcDisplay</code>.</p> <pre><code>protected void onSaveInstanceState(Bundle outState) { // Save the calculator display text. outState.putString("displayText", calcDisplay.getText()); } protected void onCreate(Bundle savedInstanceState) { // ... // Restore the calculator display text. if (savedInstanceState != null) { String displayText = savedInstanceState.getString("displayText"); calcDisplay.setText(displayText); } } </code></pre> <p>Using this code, the device will not only automatically restore the calculator display text on rotation, but since the activity is destroyed and recreated, the font size you want will be loaded as well.</p>
 

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