Change android window size with setScaleX() setScaleY()
<p>I am adding a view using the WindowManager.</p>

<p>In the <code>WindowManager.LayoutParameters</code> I am setting both width and height to WRAP_CONTENT as the content should dictate how large the view should be.</p>

<p>However, I am allowing the user to adjust the overall size of the layout.</p>

<p>Then, when I create the layout, I simply apply the saved scale value and viola it shows the newly resized view.</p>

<p>The problem is that despite scaling the actual view I add as shown below:</p>

<pre><code>myView.setScaleX(scaleFactor);
myView.setScaleY(scaleFactor);
mWindowManager.addView(myView, params);
</code></pre>

<p>There still seems to be some sort of "container" around my shrunk view.</p>

<p>So I figured instead of using <code>setScaleX()</code> and <code>setScaleY()</code>, to instead add a runnable to my view to run after its done drawing and calling <code>getWidth()</code> and <code>getHeight()</code> then using my <code>scaleFactor</code> value to compute the new height and width. This works, but now things are getting cut off because <code>setScaleX()</code> and <code>setScaleY()</code> actually shrinks <em>everything</em> inside the view. The entire <code>Paint</code> object is shrunk including text, space between text and everything.</p>

<p>Does anyone know how I can make the absolute dimensions the same size as the shrunk view?</p>

<p>EDIT: So after messing around with this. What I believe I need to do is figure out how to resize the parent layout and allowing its children to be clipped instead of resized.</p>

<p>For instance:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:id="@+id/parent_layout"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"&gt;

    &lt;TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"/&gt;
&lt;/RelativeLayout&gt;
</code></pre>

<p>In the layout above, I scale the <code>TextView</code> object using <code>setScaleX()</code> and <code>setScaleY()</code> this causes the textView to be scaled but doesn't change its actual dimensions.</p>

<p>What I need to do then, is get the dimensions of the <code>RelativeLayout</code> and multiply it by the float scale value. This will get the new dimensions. Then I need to update those dimensions WITHOUT changing the dimensions of the <code>TextView</code> oject.</p>