Match height of staticlayout to notification height in notification with custom layout
<p>I am creating an app for a non-English market. Hence, I have to change the font of the notification. So I have to use Bitmap. I want the notification to be multiline. I have the following code. </p>

<pre><code>        DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
        int width = displayMetrics.widthPixels;

        Bitmap bitmapTitle = Bitmap.createBitmap(width - 72, 84, Bitmap.Config.ARGB_8888);
        Canvas canvasTitle = new Canvas(bitmapTitle);
        TextPaint paintTitle = new TextPaint();
        paintTitle.setAntiAlias(true);
        paintTitle.setSubpixelText(true);
        paintTitle.setTypeface(AppApplication.hindiFont);
        paintTitle.setStyle(Paint.Style.FILL);
        paintTitle.setColor(ContextCompat.getColor(context, R.color.positive));
        paintTitle.setTextSize(70);
        paintTitle.setFakeBoldText(true);
        paintTitle.setTextAlign(Paint.Align.LEFT);
        String longText = "vuqla/kkuksa ls irk pyk fd bl enn djrk gS fd yksx dSyksjh dh la[;k os miHkksx dks de dj fn;k gSA";
        StaticLayout staticLayout = new StaticLayout(longText, paintTitle, canvasTitle.getWidth(), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); 
        canvasTitle.save();
        staticLayout.draw(canvasTitle);
        canvasTitle.restore();
</code></pre>

<p>I am not using <code>canvasTitle.drawText()</code> as this cannot wrap a long string according to the width of the notification. Hence, I followed the method shown <a href="https://stackoverflow.com/a/8369690/5512020">here</a> suggesting the use of staticlayout. </p>

<p>I get the following output: 
<a href="https://i.stack.imgur.com/qkTmS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qkTmS.png" alt="enter image description here"></a></p>

<p>Here only the top of the next line is displayed but not the full line. How to get the full line to be displayed using the static layout? Or why is it not displayed fully?</p>

<p>Here is the xml:</p>

<pre><code>&lt;LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/custom_notification"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:padding="2dp"&gt;

&lt;ImageView
    android:id="@+id/rnotification_iv_logo"
    android:layout_width="40dp"
    android:layout_height="40dp"
    android:layout_marginLeft="5dp"
    android:layout_marginRight="5dp"
    android:layout_gravity="center_vertical"
    android:src="@drawable/notification_icon"/&gt;

&lt;ImageView
    android:id="@+id/rnotification_iv_title"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_marginTop="2dp"
    android:layout_gravity="center_vertical"
    android:paddingRight="5dp" /&gt;

&lt;/LinearLayout&gt;
</code></pre>