<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mark Frelih on Medium]]></title>
        <description><![CDATA[Stories by Mark Frelih on Medium]]></description>
        <link>https://medium.com/@mark.frelih_9464?source=rss-4876756ba13a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*oJdLDmkprIkwH4RioEHhmw.png</url>
            <title>Stories by Mark Frelih on Medium</title>
            <link>https://medium.com/@mark.frelih_9464?source=rss-4876756ba13a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 07:03:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mark.frelih_9464/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to Handle Automatic Content Resizing when keyboard is visible in Jetpack Compose]]></title>
            <link>https://medium.com/@mark.frelih_9464/how-to-handle-automatic-content-resizing-when-keyboard-is-visible-in-jetpack-compose-1c76e0e17c57?source=rss-4876756ba13a------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c76e0e17c57</guid>
            <category><![CDATA[android-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Mark Frelih]]></dc:creator>
            <pubDate>Thu, 02 Mar 2023 01:24:52 GMT</pubDate>
            <atom:updated>2024-05-21T12:46:45.549Z</atom:updated>
            <content:encoded><![CDATA[<p>As Android developers, we have all encountered the problem of the keyboard overlapping the content of our app, which can be frustrating for users.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LqnlxQPmmFfMtKeK.png" /></figure><p>In this article, we will explore how to implement automatic content resizing when the keyboard is visible in Jetpack Compose. Before, we start let’s see what are we talking about:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/428/1*5uRM2cdOb4ROhfT5N3NpLw.gif" /><figcaption>Keyboard overlaps the content example</figcaption></figure><p>In the past we would have solved this problem by adding next line to AndroidManifest.xml file:</p><pre>android:windowSoftInputMode=&quot;adjustResize&quot;</pre><p>However, in a Compose-only app, this solution doesn’t work, so we need to find an alternative solution.</p><p>We came up with a reusable component that uses the .imePaddingmodifier to automatically add padding whenever a keyboard is opened:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f2c0ea17fabfadeffaf94ffdca6fe937/href">https://medium.com/media/f2c0ea17fabfadeffaf94ffdca6fe937/href</a></iframe><p>This simple component takes in content and ensures that it resizes automatically when the keyboard is opened. The usage of this component is straightforward and can be seen below:</p><pre> KeyboardAware {<br>    SearchSongScreen(...)       <br> }</pre><p>And the result is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/428/1*Xp9vSTgY1d2eFegiv_9t1Q.gif" /><figcaption>Content resizes automatically when keyboard is opened example</figcaption></figure><p>However, we soon realized that if we needed to have multiple TextFieldson one screen, the content would overlap again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/428/1*PXj9YJxEyse91vYwgfcTNQ.gif" /><figcaption>Keyboard overlaps the content again example</figcaption></figure><p>We somehow need to make the content scrollable as well in this case. For this we are going to need a couple more things:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a64ad04d5aa07284f09cd7dee986ac07/href">https://medium.com/media/a64ad04d5aa07284f09cd7dee986ac07/href</a></iframe><p>We need to add scrollState that we pass to .verticalScroll modifier to our screen.</p><p>We need to create coroutineScope with rememberCoroutineScope . This creates a <strong>composition-aware </strong>scope, that we can use to launch a coroutine outside a composable.</p><p>In the end we also need to get the height of our keyboard of course. This can be done with WindowInsets.ime.getBottom(LocalDensity.current) .</p><p>To wire everything up and get a working example, we use LaunchedEffect with keyboardHeight as a key. This means that that the block we pass to our LaunchedEffect will be (re)launched whenever the height of our keyboard changes. Exactly what we need!</p><p>Lastly we call scrollState.scrollBy(keyboardHeight.toFloat()) , which will scroll our content by the height of our keyboard. We need to use our coroutineScope that we created earlier here, since scrollBy is a suspend function.</p><p>The final solution looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/428/1*E2MdREPidgMZFSoTn_pHpg.gif" /><figcaption>The final scrollable resizing content example</figcaption></figure><p>And that’s it! 🥳 We have a final solution that should work with literally any screen. I hope you find this short tutorial useful. 👨‍💻</p><p>Full code available at: <a href="https://github.com/Kuglll/KeyboarAwareSample/tree/main">https://github.com/Kuglll/KeyboarAwareSample/tree/main</a></p><p><strong>If you want to connect with me, feel free to do so on </strong><a href="https://github.com/Kuglll"><strong>Github</strong></a><strong> or </strong><a href="https://www.linkedin.com/in/mark-frelih-547208174/"><strong>LinkedIn</strong></a><strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c76e0e17c57" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to have multiple styles within Jetpack Compose Text]]></title>
            <link>https://medium.com/@mark.frelih_9464/how-to-have-multiple-styles-within-jetpack-compose-text-2b6d2c3174d8?source=rss-4876756ba13a------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b6d2c3174d8</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Mark Frelih]]></dc:creator>
            <pubDate>Thu, 05 Jan 2023 23:01:25 GMT</pubDate>
            <atom:updated>2023-01-05T23:01:25.894Z</atom:updated>
            <content:encoded><![CDATA[<p>This article will talk about how to have multiple styles within a single Text using Jetpack Compose.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VNG_Qrrsp_QI8hUu.png" /></figure><p>Remember how every time you needed to have multiple styles applied to a single TextView in XML you stumbled upon a solution that either used Html.fromHtml or SpannableString together with some index magic.</p><p>Well, those days are over. Using Jetpack Compose we can easily achieve that with AnnotatedString . We can build it with buildAnnotatedString and just pass it to Text composable.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c3dd80dd43158eee7bcd7aa4226c4c03/href">https://medium.com/media/c3dd80dd43158eee7bcd7aa4226c4c03/href</a></iframe><p>Will give us:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*HoooQ1qO5vo0-O1j0pnCuQ.png" /></figure><p>The nice thing is that if you set a color to the text directly, for example, the AnnotatedString will use it by default as well. You can then still override it with SpanStyle later.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e35711f686306e989dd4b0916fb35b56/href">https://medium.com/media/e35711f686306e989dd4b0916fb35b56/href</a></iframe><p>Will give us:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*MAnekOXWQVP1iET09PXQTA.png" /></figure><p>Things you can also customise with SpanStyle are:</p><ul><li>color</li><li>fontSize</li><li>fontWeight</li><li>fontStyle</li><li>fontFamily</li><li>background</li><li>textDecoration</li><li>shadow</li><li>and many more!</li></ul><p><strong>That’s it! Thanks for reading my first article! 🥳</strong></p><p><strong>If you want, we can connect on </strong><a href="https://github.com/Kuglll"><strong>Github</strong></a><strong> or </strong><a href="https://www.linkedin.com/in/mark-frelih-547208174/"><strong>LinkedIn</strong></a><strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b6d2c3174d8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>