You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mercury-parser/fixtures/medium.com--another.html

37 lines
69 KiB
HTML

<!doctype html><html lang="en"><head><title data-rh="true">Flag Attributes in Android &#x2014; How to Use Them | by Jakob Ulbrich | Medium</title><meta data-rh="true" charset="utf-8"><meta data-rh="true" name="viewport" value="width=device-width,minimum-scale=1,initial-scale=1,maximum-scale=1"><meta data-rh="true" name="theme-color" value="#000000"><meta data-rh="true" name="twitter:app:name:iphone" value="Medium"><meta data-rh="true" name="twitter:app:id:iphone" value="828256236"><meta data-rh="true" value="Medium" name="al:ios:app_name"><meta data-rh="true" value="828256236" name="al:ios:app_store_id"><meta data-rh="true" value="com.medium.reader" name="al:android:package"><meta data-rh="true" value="542599432471018" name="fb:app_id"><meta data-rh="true" value="Medium" name="og:site_name"><meta data-rh="true" value="article" name="og:type"><meta data-rh="true" value="2018-01-19T17:06:07.358Z" name="article:published_time"><meta data-rh="true" name="title" value="Flag Attributes in Android &#x2014; How to Use Them | by Jakob Ulbrich | Medium"><meta data-rh="true" value="Flag Attributes in Android &#x2014; How to Use Them" name="og:title"><meta data-rh="true" value="Flag Attributes in Android &#x2014; How to Use Them" name="twitter:title"><meta data-rh="true" name="twitter:site" value="@Medium"><meta data-rh="true" name="twitter:app:url:iphone" value="medium://p/ac4ec8aee7d1"><meta data-rh="true" value="medium://p/ac4ec8aee7d1" name="al:android:url"><meta data-rh="true" value="medium://p/ac4ec8aee7d1" name="al:ios:url"><meta data-rh="true" value="Medium" name="al:android:app_name"><meta data-rh="true" name="description" value="I&#x2019;m sure you have seen something like the following line very often while writing the XML attributes for your views or layouts. Notice the | between the options. It is not only a fancy separator, it&#x2026;"><meta data-rh="true" value="I&#x2019;m sure you have seen something like the following line very often while writing the XML attributes for your views or layouts." name="og:description"><meta data-rh="true" value="I&#x2019;m sure you have seen something like the following line very often while writing the XML attributes for your views or layouts." name="twitter:description"><meta data-rh="true" value="https://medium.com/@JakobUlbrich/flag-attributes-in-android-how-to-use-them-ac4ec8aee7d1" name="og:url"><meta data-rh="true" value="https://medium.com/@JakobUlbrich/flag-attributes-in-android-how-to-use-them-ac4ec8aee7d1" name="al:web:url"><meta data-rh="true" value="https://miro.medium.com/max/1200/1*0MdHo7i3dNPY9QwQ7dT0jQ.png" name="og:image"><meta data-rh="true" name="twitter:image:src" value="https://miro.medium.com/max/1200/1*0MdHo7i3dNPY9QwQ7dT0jQ.png"><meta data-rh="true" name="twitter:card" value="summary_large_image"><meta data-rh="true" value="https://medium.com/@JakobUlbrich" name="article:author"><meta data-rh="true" name="author" value="Jakob Ulbrich"><meta data-rh="true" name="robots" value="index,follow,max-image-preview:large"><meta data-rh="true" name="referrer" value="unsafe-url"><meta data-rh="true" name="twitter:label1" value="Reading time"><meta data-rh="true" name="twitter:data1" value="7 min read"><link data-rh="true" rel="icon" href="https://miro.medium.com/1*m-R_BkNf1Qjr1YbyOIJY2w.png"><link data-rh="true" rel="search" type="application/opensearchdescription+xml" title="Medium" href="/osd.xml"><link data-rh="true" rel="apple-touch-icon" sizes="152x152" href="https://miro.medium.com/fit/c/152/152/1*sHhtYhaCe2Uc3IU0IgKwIQ.png"><link data-rh="true" rel="apple-touch-icon" sizes="120x120" href="https://miro.medium.com/fit/c/120/120/1*sHhtYhaCe2Uc3IU0IgKwIQ.png"><link data-rh="true" rel="apple-touch-icon" sizes="76x76" href="https://miro.medium.com/fit/c/76/76/1*sHhtYhaCe2Uc3IU0IgKwIQ.png"><link data-rh="true" rel="apple-touch-icon" sizes="60x60" href="https://miro.medium.com/fit/c/60/60/1*sHhtYhaCe2Uc3IU0IgKwIQ.png"><link data-rh="true" rel="mask-icon" href="https://cdn-static-1.medium.com/_/fp/icons/Medium-Avatar-500x500.svg" color="#171717"><link data-rh="true" rel="preconnect" href="https://glyph.medium.com" crossorigin=""><link data-rh="true" id="glyph_preload_link" rel="preload" as="style" type="text/css" href="https://glyph.medium.com/css/unbound.css"><link data-rh="true" id="glyph_link" rel="stylesheet" type="text/css" href="https://glyph.medium.com/css/unbound.css"><link data-rh="true" rel="author" href="https://medium.com/@JakobUlbrich"><link data-rh="true" rel="canonical" href="https://medium.com/@JakobUlbrich/flag-attributes-in-android-how-to-use-them-ac4ec8aee7d1"><link data-rh="true" rel="alternate" href="android-app://com.medium.reader/https/medium.com/p/ac4ec8aee7d1"></head><body><div id="root"><div class="a b c"><div class="d e f g h i j k"></div><div class="l c"><div class="m n l"><div class="o p q r s t u"><div class="v w x y z ab ac ae af"><nav class="ag"><div class="ah ai aj ak d"><div class="al am an o ao u ap aq ar as at c"><a class="au av aw ax ay az ba bb bc bd be bf bg bh bi" aria-label="Homepage" rel="noopener follow" href="/"><svg viewbox="0 0 1043.63 592.71" class="bj bk"><g data-name="Layer 2"><g data-name="Layer 1"><path d="M588.67 296.36c0 163.67-131.78 296.35-294.33 296.35S0 460 0 296.36 131.78 0 294.34 0s294.33 132.69 294.33 296.36M911.56 296.36c0 154.06-65.89 279-147.17 279s-147.17-124.94-147.17-279 65.88-279 147.16-279 147.17 124.9 147.17 279M1043.63 296.36c0 138-23.17 249.94-51.76 249.94s-51.75-111.91-51.75-249.94 23.17-249.94 51.75-249.94 51.76 111.9 51.76 249.94"/></g></g></svg></a><div class="o ao"><div class="bl l bm"><div><a class="bn b bo bp bq br bs bt bu bv bw bx by bz ca cb cc cd ce cf cg ch ci cj ck" rel="noopener follow" href="/plans?source=upgrade_membership---nav_full----------------------------------">Get unlimited access</a></div></div><div class="cl cm cn"><span class="bn b bo bp co"><a class="cp cq aw ax ay az ba bb bc bd cr cs bg ct cu" href="https://rsci.app.link/?$canonical_url=https%3A%2F%2Fmedium.com/p/ac4ec8aee7d1&amp;~feature=LoOpenInAppButton&amp;~channel=ShowPostUnderUser&amp;~stage=mobileNavBar" rel="noopener follow">Open in app</a></span></div></div></div><div class="an l"></div></div><div class="ag h k j i cv"><div class="da o db u dc aq at c"><div class="cw cx cy cz"><a aria-label="Homepage" rel="noopener follow" href="/"><svg viewbox="0 0 1043.63 592.71" class="dd bk"><g data-name="Layer 2"><g data-name="Layer 1"><path d="M588.67 296.36c0 163.67-131.78 296.35-294.33 296.35S0 460 0 296.36 131.78 0 294.34 0s294.33 132.69 294.33 296.36M911.56 296.36c0 154.06-65.89 279-147.17 279s-147.17-124.94-147.17-279 65.88-279 147.16-279 147.17 124.9 147.17 279M1043.63 296.36c0 138-23.17 249.94-51.76 249.94s-51.75-111.91-51.75-249.94 23.17-249.94 51.75-249.94 51.76 111.9 51.76 249.94"/></g></g></svg></a></div><div class="l"><div class="de l"><a class="au av aw ax ay az ba bb bc bd be bf bg bh bi" rel="noopener follow" href="/"><div class="o dp"><div class="co df o dg dh di dj"><div class="l dk dl"><div><div class="cj" aria-hidden="false"><svg width="24" height="24" viewbox="0 0 24 24" fill="none" aria-label="Home"><path d="M4.5 10.75v10.5c0 .14.11.25.25.25h5c.14 0 .25-.11.25-.25v-5.5c0-.14.11-.25.25-.25h3.5c.14 0 .25.11.25.25v5.5c0 .14.11.25.25.25h5c.14 0 .25-.11.25-.25v-10.5M22 9l-9.1-6.83a1.5 1.5 0 0 0-1.8 0L2 9" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/></svg></div></div></div><div class="cm dm dl" aria-hidden="true"><svg width="24" height="24" viewbox="0 0 24 24" fill="none" aria-label="Home"><path d="M4.5 10.75v10.5c0 .14.11.25.25.25h5c.14 0 .25-.11.25-.25v-5.5c0-.14.11-.25.25-.25h3.5c.14 0 .25.11.25.25v5.5c0 .14.11.25.25.25h5c.14 0 .25-.11.25-.25v-10.5M22 9l-9.1-6.83a1.5 1.5 0 0 0-1.8 0L2 9" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/></svg></div><div class="cm dm bn b dn do">Home</div></div></div></a></div><span><a class="au av aw ax ay az ba bb bc bd be bf bg bh bi" rel="noopener follow" href="/m/signin?operation=register&amp;redirect=https%3A%2F%2Fmedium.com%2Fme%2Fnotifications&amp;source=--------------------------notifications_sidenav-----------"><div class="de l"><div class="o dp"><div class="co df o dg dh di dj"><div class="l dk dl"><div><div class="cj" aria-hidden="false"><svg width="24" height="24" viewbox="0 0 24 24" fill="none" aria-label="Notifications"><path d="M15 18.5a3 3 0 1 1-6 0" stroke="currentColor" stroke-linecap="round"/><path d="M5.5 10.53V9a6.5 6.5 0 0 1 13 0v1.53c0 1.42.56 2.78 1.57 3.79l.03.03c.26.26.4.6.4.97v2.93c0 .14-.11.25-.25.25H3.75a.25.25 0 0 1-.25-.25v-2.93c0-.37.14-.71.4-.97l.03-.03c1-1 1.57-2.37 1.57-3.79z" stroke="currentColor" stroke-linejoin="round"/></svg></div></div></div><div class="cm dm dl" aria-hidden="true"><svg width="24" height="24" viewbox="0 0 24 24" fill="none" aria-label="Notifications"><path d="M15 18.5a3 3 0 1 1-6 0" stroke="currentColor" stroke-linecap="round"/><path d="M5.5 10.53V9a6.5 6.5 0 0 1 13 0v1.53c0 1.42.56 2.78 1.57 3.79l.03.03c.26.26.4.6.4.97v2.93c0 .14-.11.25-.25.25H3.75a.25.25 0 0 1-.25-.25v-2.93c0-.37.14-.71.4-.97l.03-.03c1-1 1.57-2.37 1.57-3.79z" stroke="currentColor" stroke-linejoin="round"/></svg></div><div class="cm dm bn b dn do">Notifications</div></div></div></div></a></span><span><a class="au av aw ax ay az ba bb bc bd be bf bg bh bi" rel="noopener follow" href="/m/signin?operation=register&amp;redirect=https%3A%2F%2Fmedium.com%2Fme%2Flists&amp;source=--------------------------lists_sidenav-----------"><div class="de l"><div class="o dp"><div class="co df o dg dh di dj"><div class="l dk dl"><div><div class="cj" aria-hidden="false"><svg width="24" height="24" viewbox="0 0 24 24" fill="none" aria-label="Lists"><path d="M4.5 6.25V21c0 .2.24.32.4.2l5.45-4.09a.25.25 0 0 1 .3 0l5.45 4.09c.16.12.4 0 .4-.2V6.25a.25.25 0 0 0-.25-.25H4.75a.25.25 0 0 0-.25.25z" stroke="currentColor" stroke-linecap="round"/><path d="M8 6V3.25c0-.14.11-.25.25-.25h11.5c.14 0 .25.11.25.25V16.5" stroke="currentColor" stroke-linecap="round"/></svg></div></div></div><div class="cm dm dl" aria-hidden="true"><svg width="24" height="24" viewbox="0 0 24 24" fill="none" aria-label="Lists"><path d="M4.5 6.25V21c0 .2.24.32.4.2l5.45-4.09a.25.25 0 0 1 .3 0l5.45 4.09c.16.12.4 0 .4-.2V6.25a.25.25 0 0 0-.25-.25H4.75a.25.25 0 0 0-.25.25z" stroke="currentColor" stroke-linecap="round"/><path d="M8 6V3.25c0-.14.11-.25.25-.25h11.5c.14 0 .25.11.25.25V16.5" stroke="currentColor" stroke-linecap="round"/></svg></div><div class="cm dm bn b dn do">Lists</div></div></div></div></a></span><span><a class="au av aw ax ay az ba bb bc bd be bf bg bh bi" rel="noopener follow" href="/m/signin?operation=register&amp;redirect=https%3A%2F%2Fmedium.com%2Fme%2Fstories%2Fdrafts&amp;source=--------------------------stories_sidenav-----------"><div class="de l"><div class="o dp"><div class="co df o dg dh di dj"><div class="l dk dl"><div><div class="cj" aria-hidden="false"><svg width="24" height="24" viewbox="0 0 24 24" fill="none" aria-label="Stories"><path d="M4.75 21.5h14.5c.14 0 .25-.11.25-.25V2.75a.25.25 0 0 0-.25-.25H4.75a.25.25 0 0 0-.25.25v18.5c0 .14.11.25.25.25z" stroke="currentColor"/><path d="M8 8.5h8M8 15.5h5M8 12h8" stroke="currentColor" stroke-linecap="round"/></svg></div></div></div><div class="cm dm dl" aria-hidden="true"><svg width="24" height="24" viewbox="0 0 24 24" fill="none" aria-label="Stories"><path d="M4.75 21.5h14.5c.14 0 .25-.11.25-.25V2.75a.25.25 0 0 0-.25-.25H4.75a.25.25 0 0 0-.25.25v18.5c0 .14.11.25.25.25z" stroke="currentColor"/><path d="M8 8.5h8M8 15.5h5M8 12h8" stroke="currentColor" stroke-linecap="round"/></svg></div><div class="cm dm bn b dn do">Stories</div></div></div></div></a></span><div class="dq dr l"><hr class="ds dt du bc" aria-hidden="true"></div><span><a class="au av aw ax ay az ba bb bc bd be bf bg bh bi" rel="noopener follow" href="/m/signin?operation=register&amp;redirect=https%3A%2F%2Fmedium.com%2Fnew-story&amp;source=--------------------------new_post_sidenav-----------"><div class="de l"><div class="o dp"><div class="co df o dg dh di dj"><div class="l dk dl"><div><div class="cj" aria-hidden="false"><svg width="24" height="24" viewbox="0 0 24 24" fill="none" aria-label="Write"><path d="M14 4a.5.5 0 0 0 0-1v1zm7 6a.5.5 0 0 0-1 0h1zm-7-7H4v1h10V3zM3 4v16h1V4H3zm1 17h16v-1H4v1zm17-1V10h-1v10h1zm-1 1a1 1 0 0 0 1-1h-1v1zM3 20a1 1 0 0 0 1 1v-1H3zM4 3a1 1 0 0 0-1 1h1V3z" fill="currentColor"/><path d="M17.5 4.5l-8.46 8.46a.25.25 0 0 0-.06.1l-.82 2.47c-.07.2.12.38.31.31l2.47-.82a.25.25 0 0 0 .1-.06L19.5 6.5m-2-2l2.32-2.32c.1-.1.26-.1.36 0l1.64 1.64c.1.1.1.26 0 .36L19.5 6.5m-2-2l2 2" stroke="currentColor"/></svg></div></div></div><div class="cm dm dl" aria-hidden="true"><svg width="24" height="24" viewbox="0 0 24 24" fill="none" aria-label="Write"><path d="M14 4a.5.5 0 0 0 0-1v1zm7 6a.5.5 0 0 0-1 0h1zm-7-7H4v1h10V3zM3 4v16h1V4H3zm1 17h16v-1H4v1zm17-1V10h-1v10h1zm-1 1a1 1 0 0 0 1-1h-1v1zM3 20a1 1 0 0 0 1 1v-1H3zM4 3a1 1 0 0 0-1 1h1V3z" fill="currentColor"/><path d="M17.5 4.5l-8.46 8.46a.25.25 0 0 0-.06.1l-.82 2.47c-.07.2.12.38.31.31l2.47-.82a.25.25 0 0 0 .1-.06L19.5 6.5m-2-2l2.32-2.32c.1-.1.26-.1.36 0l1.64 1.64c.1.1.1.26 0 .36L19.5 6.5m-2-2l2 2" stroke="currentColor"/></svg></div><div class="cm dm bn b dn do">Write</div></div></div></div></a></span></div><div class="dv dw o ao"></div></div></div><div class="ah ai aj ak d"><div class="l ap ar ee as at c"><div class="ec an dp ed"><div class="ag o ao ef"><div class="eg dr l eh"></div><div class="eg dr l eh"></div><div class="eg dr l eh"></div></div></div></div></div></nav></div><main class="ei ej ek el em en l eo"><div class="l"><div class="eu ev ew ex ey l"><div class="o dy"><div class="en cf ez fa fb fc fd fe ff fg fh"><article><div class="l"><div class="fi fj fk fl fm fn fo cf fp ci l"></div><div class="l"><header class="pw-post-byline-header fq fr fs ft fu fv fw fx fy fz l"><div class="o ga u"><div class="o"><div class="gb l"><a class="au av aw ax ay az ba bb bc bd be bf bg bh bi" rel="noopener follow" href="/@JakobUlbrich?source=post_page-----ac4ec8aee7d1--------------------------------"><div class="l dp"><img alt="Jakob Ulbrich" class="l ci gd ge gf gh" src="https://miro.medium.com/fit/c/96/96/1*bkOovjlNjFTpGC0wTuyMCQ.jpeg" width="48" height="48"><div class="gc gd l ge gf gg aq"></div></div></a></div><div class="l"><div class="pw-author bn b dn do gi"><div class="gj o gk"><div><div class="cj" aria-hidden="false"><a class="au av aw ax ay az ba bb bc bd be bf bg bh bi" rel="noopener follow" href="/@JakobUlbrich?source=post_page-----ac4ec8aee7d1--------------------------------">Jakob Ulbrich</a></div></div><div class="gl gm gn go gp d"><span><button class="bn b gq bp gr gs gt gu gv gw gx bd ca gy gz ha ce cg ch ci cj ck">Follow</button></span></div></div></div><div class="o ao hb"><p class="pw-published-date bn b bo bp co"><span>Aug 8, 2016</span></p><div class="hc cj" aria-hidden="true"><span class="l" aria-hidden="true"><span class="bn b bo bp co">&#xB7;</span></span></div><div class="pw-reading-time bn b bo bp co">7 min read</div></div></div></div><div class="o ao"><div class="h k hd he hf"><div class="hg l hh"><div><div class="cj" aria-hidden="false"><button class="au av aw ax ay az ba bb bc bd be bf bg bh bi" aria-label="Share on twitter"><span class="cj hi dx hj"><svg width="24" height="24" viewbox="0 0 24 24" fill="none"><path d="M20 5.34c-.67.41-1.4.7-2.18.87a3.45 3.45 0 0 0-5.02-.1 3.49 3.49 0 0 0-1.02 2.47c0 .28.03.54.07.8a9.91 9.91 0 0 1-7.17-3.66 3.9 3.9 0 0 0-.5 1.74 3.6 3.6 0 0 0 1.56 2.92 3.36 3.36 0 0 1-1.55-.44V10c0 1.67 1.2 3.08 2.8 3.42-.3.06-.6.1-.94.12l-.62-.06a3.5 3.5 0 0 0 3.24 2.43 7.34 7.34 0 0 1-4.36 1.49l-.81-.05a9.96 9.96 0 0 0 5.36 1.56c6.4 0 9.91-5.32 9.9-9.9v-.5c.69-.49 1.28-1.1 1.74-1.81-.63.3-1.3.48-2 .56A3.33 3.33 0 0 0 20 5.33" fill="#A8A8A8"/></svg></span></button></div></div></div><div class="hg l hh"><div><div class="cj" aria-hidden="false"><button class="au av aw ax ay az ba bb bc bd be bf bg bh bi" aria-label="Share on facebook"><span class="cj hi dx hj"><svg width="24" height="24" viewbox="0 0 24 24" fill="none"><path d="M19.75 12.04c0-4.3-3.47-7.79-7.75-7.79a7.77 7.77 0 0 0-5.9 12.84 7.77 7.77 0 0 0 4.69 2.63v-5.49h-1.9v-2.2h1.9v-1.62c0-1.88 1.14-2.9 2.8-2.9.8 0 1.49.06 1.69.08v1.97h-1.15c-.91 0-1.1.43-1.1 1.07v1.4h2.17l-.28 2.2h-1.88v5.52a7.77 7.77 0 0 0 6.7-7.71" fill="#A8A8A8"/></svg></span></button></div></div></div><div class="hg l hh"><div><div class="cj" aria-hidden="false"><button class="au av aw ax ay az ba bb bc bd be bf bg bh bi" aria-label="Share on linkedin"><span class="cj hi dx hj"><svg width="24" height="24" viewbox="0 0 24 24" fill="none"><path d="M19.75 5.39v13.22a1.14 1.14 0 0 1-1.14 1.14H5.39a1.14 1.14 0 0 1-1.14-1.14V5.39a1.14 1.14 0 0 1 1.14-1.14h13.22a1.14 1.14 0 0 1 1.14 1.14zM8.81 10.18H6.53v7.3H8.8v-7.3zM9 7.67a1.31 1.31 0 0 0-1.3-1.32h-.04a1.32 1.32 0 0 0 0 2.64A1.31 1.31 0 0 0 9 7.71v-.04zm8.46 5.37c0-2.2-1.4-3.05-2.78-3.05a2.6 2.6 0 0 0-2.3 1.18h-.07v-1h-2.14v7.3h2.28V13.6a1.51 1.51 0 0 1 1.36-1.63h.09c.72 0 1.26.45 1.26 1.6v3.91h2.28l.02-4.43z" fill="#A8A8A8"/></svg></span></button></div></div></div><div class="l hh"><div><div class="cj" aria-hidden="false"><button class="au av aw ax ay az ba bb bc bd be bf bg bh bi"><span class="cj hi dx hj"><svg width="24" height="24" viewbox="0 0 24 24" fill="none"><path fill-rule="evenodd" clip-rule="evenodd" d="M3.57 14.67c0-.57.13-1.11.38-1.6l.02-.02v-.02l.02-.02c0-.02 0-.02.02-.02.12-.26.3-.52.57-.8L7.78 9v-.02l.01-.02c.44-.41.91-.7 1.44-.85a4.87 4.87 0 0 0-1.19 2.36A5.04 5.04 0 0 0 8 11.6L6.04 13.6c-.19.19-.32.4-.38.65a2 2 0 0 0 0 .9c.08.2.2.4.38.57l1.29 1.31c.27.28.62.42 1.03.42.42 0 .78-.14 1.06-.42l1.23-1.25.79-.78 1.15-1.16c.08-.09.19-.22.28-.4.1-.2.15-.42.15-.67 0-.16-.02-.3-.06-.45l-.02-.02v-.02l-.07-.14s0-.03-.04-.06l-.06-.13-.02-.02c0-.02 0-.03-.02-.05a.6.6 0 0 0-.14-.16l-.48-.5c0-.04.02-.1.04-.15l.06-.12 1.17-1.14.09-.09.56.57c.02.04.08.1.16.18l.05.04.03.06.04.05.03.04.04.06.1.14.02.02c0 .02.01.03.03.04l.1.2v.02c.1.16.2.38.3.68a1 1 0 0 1 .04.25 3.2 3.2 0 0 1 .02 1.33 3.49 3.49 0 0 1-.95 1.87l-.66.67-.97.97-1.56 1.57a3.4 3.4 0 0 1-2.47 1.02c-.97 0-1.8-.34-2.49-1.03l-1.3-1.3a3.55 3.55 0 0 1-1-2.51v-.01h-.02v.02zm5.39-3.43c0-.19.02-.4.07-.63.13-.74.44-1.37.95-1.87l.66-.67.97-.98 1.56-1.56c.68-.69 1.5-1.03 2.47-1.03.97 0 1.8.34 2.48 1.02l1.3 1.32a3.48 3.48 0 0 1 1 2.48c0 .58-.11 1.11-.37 1.6l-.02.02v.02l-.02.04c-.14.27-.35.54-.6.8L16.23 15l-.01.02-.01.02c-.44.42-.92.7-1.43.83a4.55 4.55 0 0 0 1.23-3.52L18 10.38c.18-.21.3-.42.35-.65a2.03 2.03 0 0 0-.01-.9 1.96 1.96 0 0 0-.36-.58l-1.3-1.3a1.49 1.49 0 0 0-1.06-.42c-.42 0-.77.14-1.06.4l-1.2 1.27-.8.8-1.16 1.15c-.08.08-.18.21-.29.4a1.66 1.66 0 0 0-.08 1.12l.02.03v.02l.06.14s.01.03.05.06l.06.13.02.02.01.02.01.02c.05.08.1.13.14.16l.47.5c0 .04-.02.09-.04.15l-.06.12-1.15 1.15-.1.08-.56-.56a2.3 2.3 0 0 0-.18-.19c-.02-.01-.02-.03-.02-.04l-.02-.02a.37.37 0 0 1-.1-.12c-.03-.03-.05-.04-.05-.06l-.1-.15-.02-.02-.02-.04-.08-.17v-.02a5.1 5.1 0 0 1-.28-.69 1.03 1.03 0 0 1-.04-.26c-.06-.23-.1-.46-.1-.7v.01z" fill="#A8A8A8"/></svg></span></button></div></div></div><div class="hk o ao"></div></div><div class="cl hl"><div><div class="cj" aria-hidden="false"></div></div></div></div></div><div class="hm hn ho j i d"><div class="gb l"></div><div class="hp l hh"><div><div class="cj" aria-hidden="false"><button class="au av aw ax ay az ba bb bc bd be bf bg bh bi" aria-label="Share on twitter"><span class="cj hi dx hj"><svg width="24" height="24" viewbox="0 0 24 24" fill="none"><path d="M20 5.34c-.67.41-1.4.7-2.18.87a3.45 3.45 0 0 0-5.02-.1 3.49 3.49 0 0 0-1.02 2.47c0 .28.03.54.07.8a9.91 9.91 0 0 1-7.17-3.66 3.9 3.9 0 0 0-.5 1.74 3.6 3.6 0 0 0 1.56 2.92 3.36 3.36 0 0 1-1.55-.44V10c0 1.67 1.2 3.08 2.8 3.42-.3.06-.6.1-.94.12l-.62-.06a3.5 3.5 0 0 0 3.24 2.43 7.34 7.34 0 0 1-4.36 1.49l-.81-.05a9.96 9.96 0 0 0 5.36 1.56c6.4 0 9.91-5.32 9.9-9.9v-.5c.69-.49 1.28-1.1 1.74-1.81-.63.3-1.3.48-2 .56A3.33 3.33 0 0 0 20 5.33" fill="#A8A8A8"/></svg></span></button></div></div></div><div class="hp l hh"><div><div class="cj" aria-hidden="false"><button class="au av aw ax ay az ba bb bc bd be bf bg bh bi" aria-label="Share on facebook"><span class="cj hi dx hj"><svg width="24" height="24" viewbox="0 0 24 24" fill="none"><path d="M19.75 12.04c0-4.3-3.47-7.79-7.75-7.79a7.77 7.77 0 0 0-5.9 12.84 7.77 7.77 0 0 0 4.69 2.63v-5.49h-1.9v-2.2h1.9v-1.62c0-1.88 1.14-2.9 2.8-2.9.8 0 1.49.06 1.69.08v1.97h-1.15c-.91 0-1.1.43-1.1 1.07v1.4h2.17l-.28 2.2h-1.88v5.52a7.77 7.77 0 0 0 6.7-7.71" fill="#A8A8A8"/></svg></span></button></div></div></div><div class="hp l hh"><div><div class="cj" aria-hidden="false"><button class="au av aw ax ay az ba bb bc bd be bf bg bh bi" aria-label="Share on linkedin"><span class="cj hi dx hj"><svg width="24" height="24" viewbox="0 0 24 24" fill="none"><path d="M19.75 5.39v13.22a1.14 1.14 0 0 1-1.14 1.14H5.39a1.14 1.14 0 0 1-1.14-1.14V5.39a1.14 1.14 0 0 1 1.14-1.14h13.22a1.14 1.14 0 0 1 1.14 1.14zM8.81 10.18H6.53v7.3H8.8v-7.3zM9 7.67a1.31 1.31 0 0 0-1.3-1.32h-.04a1.32 1.32 0 0 0 0 2.64A1.31 1.31 0 0 0 9 7.71v-.04zm8.46 5.37c0-2.2-1.4-3.05-2.78-3.05a2.6 2.6 0 0 0-2.3 1.18h-.07v-1h-2.14v7.3h2.28V13.6a1.51 1.51 0 0 1 1.36-1.63h.09c.72 0 1.26.45 1.26 1.6v3.91h2.28l.02-4.43z" fill="#A8A8A8"/></svg></span></button></div></div></div><div class="l hh"><div><div class="cj" aria-hidden="false"><button class="au av aw ax ay az ba bb bc bd be bf bg bh bi"><span class="cj hi dx hj"><svg width="24" height="24" viewbox="0 0 24 24" fill="none"><path fill-rule="evenodd" clip-rule="evenodd" d="M3.57 14.67c0-.57.13-1.11.38-1.6l.02-.02v-.02l.02-.02c0-.02 0-.02.02-.02.12-.26.3-.52.57-.8L7.78 9v-.02l.01-.02c.44-.41.91-.7 1.44-.85a4.87 4.87 0 0 0-1.19 2.36A5.04 5.04 0 0 0 8 11.6L6.04 13.6c-.19.19-.32.4-.38.65a2 2 0 0 0 0 .9c.08.2.2.4.38.57l1.29 1.31c.27.28.62.42 1.03.42.42 0 .78-.14 1.06-.42l1.23-1.25.79-.78 1.15-1.16c.08-.09.19-.22.28-.4.1-.2.15-.42.15-.67 0-.16-.02-.3-.06-.45l-.02-.02v-.02l-.07-.14s0-.03-.04-.06l-.06-.13-.02-.02c0-.02 0-.03-.02-.05a.6.6 0 0 0-.14-.16l-.48-.5c0-.04.02-.1.04-.15l.06-.12 1.17-1.14.09-.09.56.57c.02.04.08.1.16.18l.05.04.03.06.04.05.03.04.04.06.1.14.02.02c0 .02.01.03.03.04l.1.2v.02c.1.16.2.38.3.68a1 1 0 0 1 .04.25 3.2 3.2 0 0 1 .02 1.33 3.49 3.49 0 0 1-.95 1.87l-.66.67-.97.97-1.56 1.57a3.4 3.4 0 0 1-2.47 1.02c-.97 0-1.8-.34-2.49-1.03l-1.3-1.3a3.55 3.55 0 0 1-1-2.51v-.01h-.02v.02zm5.39-3.43c0-.19.02-.4.07-.63.13-.74.44-1.37.95-1.87l.66-.67.97-.98 1.56-1.56c.68-.69 1.5-1.03 2.47-1.03.97 0 1.8.34 2.48 1.02l1.3 1.32a3.48 3.48 0 0 1 1 2.48c0 .58-.11 1.11-.37 1.6l-.02.02v.02l-.02.04c-.14.27-.35.54-.6.8L16.23 15l-.01.02-.01.02c-.44.42-.92.7-1.43.83a4.55 4.55 0 0 0 1.23-3.52L18 10.38c.18-.21.3-.42.35-.65a2.03 2.03 0 0 0-.01-.9 1.96 1.96 0 0 0-.36-.58l-1.3-1.3a1.49 1.49 0 0 0-1.06-.42c-.42 0-.77.14-1.06.4l-1.2 1.27-.8.8-1.16 1.15c-.08.08-.18.21-.29.4a1.66 1.66 0 0 0-.08 1.12l.02.03v.02l.06.14s.01.03.05.06l.06.13.02.02.01.02.01.02c.05.08.1.13.14.16l.47.5c0 .04-.02.09-.04.15l-.06.12-1.15 1.15-.1.08-.56-.56a2.3 2.3 0 0 0-.18-.19c-.02-.01-.02-.03-.02-.04l-.02-.02a.37.37 0 0 1-.1-.12c-.03-.03-.05-.04-.05-.06l-.1-.15-.02-.02-.02-.04-.08-.17v-.02a5.1 5.1 0 0 1-.28-.69 1.03 1.03 0 0 1-.04-.26c-.06-.23-.1-.46-.1-.7v.01z" fill="#A8A8A8"/></svg></span></button></div></div></div></div></header><span class="l"></span><section><div><div class="gg as hw hx hy hz"></div><div class="ia ib ic id ie"><div class=""><h1 id="930d" class="pw-post-title if ig ih bn ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja jb jc jd gi">Flag Attributes in Android &#x2014; How to Use Them</h1></div><figure class="fr ft jf jg jh ji fn fo paragraph-image"><div role="button" tabindex="0" class="jj jk dp jl cf jm"><div class="fn fo je"><img alt="" class="cf jn jo" src="https://miro.medium.com/max/1400/1*0MdHo7i3dNPY9QwQ7dT0jQ.png" width="700" height="280" loading="lazy" role="presentation"></div></div></figure><p id="3674" class="pw-post-body-paragraph jp jq ih jr b js jt ju jv jw jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ia gi">I&#x2019;m sure you have seen something like the following line very often while writing the XML attributes for your views or layouts.</p><pre class="kn ko kp kq fz kr bt ks"><span id="cf19" class="gi kt ku ih kv b dn kw kx l ky">attribute=&quot;option1|option2&quot;</span></pre><p id="541f" class="pw-post-body-paragraph jp jq ih jr b js jt ju jv jw jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ia gi">Notice the <strong class="jr ii">|</strong> between the options. It is not only a fancy separator, it is a bitwise operator merging the two options into one single value.</p><p id="fe64" class="pw-post-body-paragraph jp jq ih jr b js jt ju jv jw jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ia gi">The following will explain what exactly Bit Flags are, how to declare custom XML flag attributes and how to read and work with them in the code.</p></div><div class="o dy kz la hm lb" role="separator"><span class="lc gd cj ld le lf"></span><span class="lc gd cj ld le lf"></span><span class="lc gd cj ld le"></span></div><div class="ia ib ic id ie"><h1 id="c9ce" class="lg ku ih bn lh li lj lk ll lm ln lo lp lq lr ls lt lu lv lw lx ly lz ma mb mc gi">What Are Bit Flags?</h1><p id="ea8a" class="pw-post-body-paragraph jp jq ih jr b js md ju jv jw me jy jz ka mf kc kd ke mg kg kh ki mh kk kl km ia gi">Generally you can see Bit Flags as a number of boolean values stored in one single value.</p><p id="6368" class="pw-post-body-paragraph jp jq ih jr b js jt ju jv jw jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ia gi">In the binary system a bit has two states: <strong class="jr ii">on</strong> and <strong class="jr ii">off</strong>. Now think about a row of bits where every bit is an indicator for one of your options. When the option is set, the bit has the value 1. If not, it has the value 0.</p><pre class="kn ko kp kq fz kr bt ks"><span id="ff9e" class="gi kt ku ih kv b dn kw kx l ky">110</span></pre><p id="eac5" class="pw-post-body-paragraph jp jq ih jr b js jt ju jv jw jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ia gi">We read this <strong class="jr ii">from right to left</strong>.<br>The bit for our first option is <strong class="jr ii">0</strong>. That means the option is <strong class="jr ii">not set</strong>. Whereas the bits for the second and third options are <strong class="jr ii">1</strong>. This means they are <strong class="jr ii">set</strong>.</p><p id="b6da" class="pw-post-body-paragraph jp jq ih jr b js jt ju jv jw jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ia gi">Every integer value has a representation in the binary system and and vice versa.</p><pre class="kn ko kp kq fz kr bt ks"><span id="1b00" class="gi kt ku ih kv b dn kw kx l ky">0 = <strong class="kv ii">0</strong>*2&#xB3; + <strong class="kv ii">0</strong>*2&#xB2; + <strong class="kv ii">0</strong>*2&#xB9; + <strong class="kv ii">0</strong>*2&#x2070; = 0000<br>1 = <strong class="kv ii">0</strong>*2&#xB3; + <strong class="kv ii">0</strong>*2&#xB2; + <strong class="kv ii">0</strong>*2&#xB9; + <strong class="kv ii">1</strong>*2&#x2070; = 0001<br>2 = <strong class="kv ii">0</strong>*2&#xB3; + <strong class="kv ii">0</strong>*2&#xB2; + <strong class="kv ii">1</strong>*2&#xB9; + <strong class="kv ii">0</strong>*2&#x2070; = 0010<br>4 = <strong class="kv ii">0</strong>*2&#xB3; + <strong class="kv ii">1</strong>*2&#xB2; + <strong class="kv ii">0</strong>*2&#xB9; + <strong class="kv ii">0</strong>*2&#x2070; = 0100<br>8 = <strong class="kv ii">1</strong>*2&#xB3; + <strong class="kv ii">0</strong>*2&#xB2; + <strong class="kv ii">0</strong>*2&#xB9; + <strong class="kv ii">0</strong>*2&#x2070; = 1000</span></pre><p id="2244" class="pw-post-body-paragraph jp jq ih jr b js jt ju jv jw jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ia gi">This means we can store our Bit Flag value as a plain integer value. And we can use the bitwise operators (more about them later) directly on integer values.</p></div><div class="o dy kz la hm lb" role="separator"><span class="lc gd cj ld le lf"></span><span class="lc gd cj ld le lf"></span><span class="lc gd cj ld le"></span></div><div class="ia ib ic id ie"><h1 id="98b3" class="lg ku ih bn lh li lj lk ll lm ln lo lp lq lr ls lt lu lv lw lx ly lz ma mb mc gi">Declaring XML Flag Attributes</h1><p id="557e" class="pw-post-body-paragraph jp jq ih jr b js md ju jv jw me jy jz ka mf kc kd ke mg kg kh ki mh kk kl km ia gi">Now, let&#x2019;s assume that we want to create a custom view called <strong class="jr ii">MyView</strong> which can draw a border around itself, and that we want to specify on which sites (top, right, bottom, left) it should draw the borders using an XML flag attribute.<br>I will <strong class="jr ii">not</strong> explain how to actually draw something, I will only explain how to work with flags.</p><p id="d1a0" class="pw-post-body-paragraph jp jq ih jr b js jt ju jv jw jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ia gi">We can declare XML flag attributes like any other attribute. You can find an official documentation <a class="au mi" href="https://developer.android.com/training/custom-views/create-view.html#customattr" rel="noopener ugc nofollow" target="_blank">here</a>.</p><p id="3d1c" class="pw-post-body-paragraph jp jq ih jr b js jt ju jv jw jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ia gi">In our <strong class="jr ii">values/attrs.xml</strong> file we declare the new attribute called <strong class="jr ii">drawBorder</strong> for our view called <strong class="jr ii">MyView</strong>.</p><pre class="kn ko kp kq fz kr bt ks"><span id="6dda" class="gi kt ku ih kv b dn kw kx l ky">&lt;resources&gt;<br> &lt;declare-styleable name=&quot;<strong class="kv ii">MyView</strong>&quot;&gt;<br> &lt;attr name=&quot;<strong class="kv ii">drawBorder</strong>&quot;&gt;<br> &lt;flag name=&quot;none&quot; value=&quot;<strong class="kv ii">0</strong>&quot; /&gt;<br> &lt;flag name=&quot;top&quot; value=&quot;<strong class="kv ii">1</strong>&quot; /&gt;<br> &lt;flag name=&quot;right&quot; value=&quot;<strong class="kv ii">2</strong>&quot; /&gt;<br> &lt;flag name=&quot;bottom&quot; value=&quot;<strong class="kv ii">4</strong>&quot; /&gt;<br> &lt;flag name=&quot;left&quot; value=&quot;<strong class="kv ii">8</strong>&quot; /&gt;<br> &lt;flag name=&quot;all&quot; value=&quot;<strong class="kv ii">15</strong>&quot; /&gt;<br> &lt;/attr&gt;<br> ...<br> &lt;/declare-styleable&gt;<br>&lt;/resources&gt;</span></pre><p id="273e" class="pw-post-body-paragraph jp jq ih jr b js jt ju jv jw jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ia gi">Look exactly at the values we have set for the options.<br>We essentially have 4 options (top, right, bottom, left). The other two options are used to specify that no option is set or that all options are set.<br>The values for the 4 options are chosen, so that when you write them in the binary system, these two statements are fulfilled:</p><ul class=""><li id="dc67" class="mj mk ih jr b js jt jw jx ka ml ke mm ki mn km mo mp mq mr gi">Every value has exactly one bit which is set to 1. All other bits are 0.</li><li id="e466" class="mj mk ih jr b js ms jw mt ka mu ke mv ki mw km mo mp mq mr gi">None of the values have the same bit set to 1.</li></ul><figure class="kn ko kp kq fz ji fn fo paragraph-image"><div role="button" tabindex="0" class="jj jk dp jl cf jm"><div class="fn fo mx"><img alt="" class="cf jn jo" src="https://miro.medium.com/max/1400/1*C40RkP6OklGFMd9vK-zYJQ.png" width="700" height="380" loading="lazy" role="presentation"></div></div></figure><p id="009e" class="pw-post-body-paragraph jp jq ih jr b js jt ju jv jw jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ia gi">The option <strong class="jr ii"><em class="my">none</em></strong> is used to indicate that none of the 4 options is set. And the option <strong class="jr ii"><em class="my">all</em></strong> is the sum of the values of the 4 options and indicates that all of the 4 options are set.</p><p id="4a0b" class="pw-post-body-paragraph jp jq ih jr b js jt ju jv jw jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ia gi">We can now use our custom attribute like this in our custom View:</p><pre class="kn ko kp kq fz kr bt ks"><span id="eb42" class="gi kt ku ih kv b dn kw kx l ky">&lt;my.package.name.MyView<br> android:layout_width=&quot;match_parent&quot;<br> android:layout_height=&quot;wrap_content&quot;<br> app:drawBorder=&quot;bottom|top&quot; /&gt;</span></pre></div><div class="o dy kz la hm lb" role="separator"><span class="lc gd cj ld le lf"></span><span class="lc gd cj ld le lf"></span><span class="lc gd cj ld le"></span></div><div class="ia ib ic id ie"><h1 id="237a" class="lg ku ih bn lh li lj lk ll lm ln lo lp lq lr ls lt lu lv lw lx ly lz ma mb mc gi">Read XML Flag Attributes</h1><p id="721e" class="pw-post-body-paragraph jp jq ih jr b js md ju jv jw me jy jz ka mf kc kd ke mg kg kh ki mh kk kl km ia gi">Let&#x2019;s start with the basic class for our custom View. We should declare a constant for each of our options with an equal value as declared above. And a variable for the value that we get from reading the XML attribute. You can have a look about how to read attributes <a class="au mi" href="https://developer.android.com/training/custom-views/create-view.html#applyattr" rel="noopener ugc nofollow" target="_blank">here</a>.</p><pre class="kn ko kp kq fz kr bt ks"><span id="1653" class="gi kt ku ih kv b dn kw kx l ky">public MyView extends View{</span><span id="8776" class="gi kt ku ih kv b dn mz na nb nc nd kx l ky"> <strong class="kv ii">// Constants for the flags<br> private static final int BORDER_NONE_DEFAULT = 0;<br> private static final int BORDER_TOP = 1;<br> private static final int BORDER_RIGHT = 2;<br> private static final int BORDER_BOTTOM = 4;<br> private static final int BORDER_LEFT = 8;</strong></span><span id="546c" class="gi kt ku ih kv b dn mz na nb nc nd kx l ky"><strong class="kv ii"> // Variable for the current value<br> private int mDrawBorder = BORDER_NONE_DEFAULT;</strong></span><span id="5cde" class="gi kt ku ih kv b dn mz na nb nc nd kx l ky"> public MyView(Context context){<br> // Delegate to next constructor<br> this(context, null);<br> }</span><span id="f925" class="gi kt ku ih kv b dn mz na nb nc nd kx l ky"> public MyView(Context context, AttributeSet attrs){<br> // Delegate to next constructor<br> this(context, attrs, 0); <br> }</span><span id="538b" class="gi kt ku ih kv b dn mz na nb nc nd kx l ky"> public MyView(Context context, AttributeSet attrs,<br> int defStyleAttr){<br> super(context, attrs, defStyleAttr);</span><span id="6f1a" class="gi kt ku ih kv b dn mz na nb nc nd kx l ky"> <strong class="kv ii">// Read attributes<br> TypedArray a = context.getTheme().obtainStyledAttributes(<br> attrs, R.styleable.MyView);</strong></span><span id="38b1" class="gi kt ku ih kv b dn mz na nb nc nd kx l ky"><strong class="kv ii"> try {<br> mDrawBorder = a.getInteger(<br> R.styleable.MyView_drawBorder,<br> BORDER_NONE_DEFAULT);<br> } finally {<br> a.recycle();<br> }</strong><br> }<br> ...<br>}</span></pre><p id="6354" class="pw-post-body-paragraph jp jq ih jr b js jt ju jv jw jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ia gi">We have now assigned the value specified in the XML layout file to the <strong class="jr ii"><em class="my">mDrawBorder</em></strong> variable. If the attribute does not exists in the layout the <strong class="jr ii"><em class="my">BORDER_NONE_DEFAULT</em></strong> value is used.</p></div><div class="o dy kz la hm lb" role="separator"><span class="lc gd cj ld le lf"></span><span class="lc gd cj ld le lf"></span><span class="lc gd cj ld le"></span></div><div class="ia ib ic id ie"><h1 id="e1c8" class="lg ku ih bn lh li lj lk ll lm ln lo lp lq lr ls lt lu lv lw lx ly lz ma mb mc gi">Working With Bit Flags</h1><p id="551a" class="pw-post-body-paragraph jp jq ih jr b js md ju jv jw me jy jz ka mf kc kd ke mg kg kh ki mh kk kl km ia gi">Okay, how do we know which of our options were set when we only get one value? That&#x2019;s why we have defined the constants for our options.</p><p id="5a09" class="pw-post-body-paragraph jp jq ih jr b js jt ju jv jw jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ia gi">There are bitwise operators we can use to check if an option is contained in the current <strong class="jr ii">mDrawBorder</strong> value and to enable or disable or toggle an option. Let&#x2019;s have a look at them:</p><pre class="kn ko kp kq fz kr bt ks"><span id="b2e4" class="gi kt ku ih kv b dn kw kx l ky"><strong class="kv ii">| (bitwise logically or)</strong><br>Example: 100 | 001 = 101<br>The result has a 1 on the position where at least one value has a 1.</span><span id="8458" class="gi kt ku ih kv b dn mz na nb nc nd kx l ky"><strong class="kv ii">&amp; (bitwise logically and)</strong><br>Example: 100 &amp; 101 = 100<br>The result has a 1 on the position where both values have a 1.</span><span id="0115" class="gi kt ku ih kv b dn mz na nb nc nd kx l ky"><strong class="kv ii">~ (bitwise inverse)</strong><br>Example: ~100 = 011<br>All bits get inverted.</span><span id="af80" class="gi kt ku ih kv b dn mz na nb nc nd kx l ky"><strong class="kv ii">^ (bitwise exclusive or)</strong><br>Example: 100^101 = 001<br>The result has a 1 on the position where one value has a 1 whereas the other value has a 0.</span></pre><p id="c03f" class="pw-post-body-paragraph jp jq ih jr b js jt ju jv jw jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ia gi">Let&#x2019;s assume we have used the attribute in the following two ways. Yes, technically they are correct, but they may look weird&#xA0;&#x1F635;.</p><pre class="kn ko kp kq fz kr bt ks"><span id="fd22" class="gi kt ku ih kv b dn kw kx l ky"><strong class="kv ii">Example 1:</strong> app:drawBorder=&quot;none|top&quot;</span></pre><p id="096d" class="pw-post-body-paragraph jp jq ih jr b js jt ju jv jw jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ia gi">In this first example the values of <strong class="jr ii"><em class="my">none</em></strong> (0 = 000) and <strong class="jr ii"><em class="my">top</em></strong> (1 = 001) get combined by the logically or-operator <strong class="jr ii">|</strong> to the value (001 = 1). The result still contains the flag value for <strong class="jr ii"><em class="my">top</em></strong> (which is 1). And also for <strong class="jr ii"><em class="my">none</em></strong> (which is 0) because every flag-set contains the 0-flag at every time.</p><pre class="kn ko kp kq fz kr bt ks"><span id="e78b" class="gi kt ku ih kv b dn kw kx l ky"><strong class="kv ii">Example 2:</strong> app:drawBorder=&quot;bottom|all&quot;</span></pre><p id="61e7" class="pw-post-body-paragraph jp jq ih jr b js jt ju jv jw jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ia gi">In this second example the values of <strong class="jr ii"><em class="my">bottom</em></strong> (3 =0011) and <strong class="jr ii"><em class="my">all</em></strong> (15 = 1111) get combined to (1111 = 15). The result still contains the flag for <strong class="jr ii"><em class="my">bottom</em></strong> since <strong class="jr ii"><em class="my">all</em></strong> enables the bits for all of the 4 options.</p><h2 id="3f0a" class="kt ku ih bn lh ne nf ng ll nh ni nj lp ka nk nl lt ke nm nn lx ki no np mb nq gi">Check If a Flag is Contained in The Set</h2><p id="914e" class="pw-post-body-paragraph jp jq ih jr b js md ju jv jw me jy jz ka mf kc kd ke mg kg kh ki mh kk kl km ia gi">Now we need to check which option is contained in the value of the <strong class="jr ii"><em class="my">mDrawBorder</em></strong> variable. We do this by calling the following method:</p><pre class="kn ko kp kq fz kr bt ks"><span id="349d" class="gi kt ku ih kv b dn kw kx l ky">private boolean containsFlag(int flagSet, int flag){<br> <strong class="kv ii">return (flagSet|flag) == flagSet;</strong><br>}</span><span id="efc1" class="gi kt ku ih kv b dn mz na nb nc nd kx l ky">// Method call<br>boolean drawBorderTop = containsFlag(mDrawBorder, BORDER_TOP);</span></pre><p id="a327" class="pw-post-body-paragraph jp jq ih jr b js jt ju jv jw jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ia gi">We try to add the flag to the existing flag-set and if the value of the flag-set does not change, we can combine that the flag was already contained.</p><h2 id="0923" class="kt ku ih bn lh ne nf ng ll nh ni nj lp ka nk nl lt ke nm nn lx ki no np mb nq gi">Add a Flag to The Set</h2><p id="4c67" class="pw-post-body-paragraph jp jq ih jr b js md ju jv jw me jy jz ka mf kc kd ke mg kg kh ki mh kk kl km ia gi">Adding a flag is pretty simple. We use the same operator (The logically or-operator) like in the XML attributes:</p><pre class="kn ko kp kq fz kr bt ks"><span id="a87d" class="gi kt ku ih kv b dn kw kx l ky">private int addFlag(int flagSet, int flag){<br> <strong class="kv ii">return flagSet|flag;</strong><br>}</span><span id="0290" class="gi kt ku ih kv b dn mz na nb nc nd kx l ky">// Method call<br>mDrawBorder = addFlag(mDrawBorder, BORDER_LEFT);</span></pre><p id="f35e" class="pw-post-body-paragraph jp jq ih jr b js jt ju jv jw jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ia gi">We do not need to check if the flag-set already contains the flag that we want to add. When it is already contained, the value simply stays the same.</p><h2 id="ee74" class="kt ku ih bn lh ne nf ng ll nh ni nj lp ka nk nl lt ke nm nn lx ki no np mb nq gi">Toggle a Flag in The Set</h2><p id="d7c2" class="pw-post-body-paragraph jp jq ih jr b js md ju jv jw me jy jz ka mf kc kd ke mg kg kh ki mh kk kl km ia gi">Toggling is also very simple.</p><pre class="kn ko kp kq fz kr bt ks"><span id="5c8b" class="gi kt ku ih kv b dn kw kx l ky">private int toggleFlag(int flagSet, int flag){<br> <strong class="kv ii">return flagSet^flag;</strong><br>}</span><span id="b8a6" class="gi kt ku ih kv b dn mz na nb nc nd kx l ky">// Method call<br>mDrawBorder = toggleFlag(mDrawBorder, BORDER_LEFT);</span></pre><p id="fa65" class="pw-post-body-paragraph jp jq ih jr b js jt ju jv jw jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ia gi">Since the exclusive or-operator <strong class="jr ii">^</strong> only keeps the bits where both bits are different, it will remove the bits that are set in the flag when they are also already set in the flag-set. And it will add them if they are not set in the flag-set.</p><pre class="kn ko kp kq fz kr bt ks"><span id="2b34" class="gi kt ku ih kv b dn kw kx l ky"><strong class="kv ii">Example 1:</strong> 110^010 = 100 (Binary)<br> 6 ^ 2 = 4 (Decimal)</span><span id="cf5e" class="gi kt ku ih kv b dn mz na nb nc nd kx l ky"><strong class="kv ii">Example 2:</strong> 100^010 = 110 (Binary)<br> 4 ^ 2 = 6 (Decimal)</span></pre><h2 id="fe39" class="kt ku ih bn lh ne nf ng ll nh ni nj lp ka nk nl lt ke nm nn lx ki no np mb nq gi">Remove a Flag From the Set</h2><p id="5bfd" class="pw-post-body-paragraph jp jq ih jr b js md ju jv jw me jy jz ka mf kc kd ke mg kg kh ki mh kk kl km ia gi">Removing a flag is a bit more complicated (we need two bitwise operators), but still easy.</p><pre class="kn ko kp kq fz kr bt ks"><span id="5f92" class="gi kt ku ih kv b dn kw kx l ky">private int removeFlag(int flagSet, int flag){<br> <strong class="kv ii">return flagSet&amp;(~flag);</strong><br>}</span><span id="0e7a" class="gi kt ku ih kv b dn mz na nb nc nd kx l ky">// Method call<br>mDrawBorder = removeFlag(mDrawBorder, BORDER_LEFT);</span></pre><p id="9031" class="pw-post-body-paragraph jp jq ih jr b js jt ju jv jw jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ia gi">First we invert the flag that we want to remove. Then we combine this with the current flag-set. This means only where the bit in the flag was set, we now have a 0. And that&#x2019;s why we also have a 0 at this position in the final result. The rest of the result is the same as in the original flag-set. Have a look at this example:</p><pre class="kn ko kp kq fz kr bt ks"><span id="dd43" class="gi kt ku ih kv b dn kw kx l ky">110&amp;(~010) = 110&amp;101 = 100 (Binary)<br> 6 &amp;(~ 2 ) = 6 &amp; 5 = 4 (Decimal)</span></pre></div><div class="o dy kz la hm lb" role="separator"><span class="lc gd cj ld le lf"></span><span class="lc gd cj ld le lf"></span><span class="lc gd cj ld le"></span></div><div class="ia ib ic id ie"><p id="fde9" class="pw-post-body-paragraph jp jq ih jr b js jt ju jv jw jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ia gi">Bit Flags are also a good alternative if you have a lot of boolean values and especially if you want to store them somehow. Instead of saving a lot of booleans you only need to save one integer value.</p><p id="a523" class="pw-post-body-paragraph jp jq ih jr b js jt ju jv jw jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ia gi">You should now be able to define your own flag attributes and work with them in your application. You should also be able to use Bit Flags as an alternative to a number of booleans.<br>When you found this tutorial useful feel free to hit the &#x1F49A;.</p></div><div class="o dy kz la hm lb" role="separator"><span class="lc gd cj ld le lf"></span><span class="lc gd cj ld le lf"></span><span class="lc gd cj ld le"></span></div><div class="ia ib ic id ie"><p id="c1ec" class="pw-post-body-paragraph jp jq ih jr b js jt ju jv jw jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ia gi">If you have any suggestions on how to improve this tutorial or found a mistake, you can leave a private note at the specific position.</p><p id="5752" class="pw-post-body-paragraph jp jq ih jr b js jt ju jv jw jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km ia gi">Happy coding &#x1F4BB;.</p></div></div></section></div></div></article><div class="nr o"></div></div></div><div class="l"></div><footer class="ns nt nu nv o ao nw nx c"><div class="l ny"><div class="o dy"><div class="en cf ez fa fb fc fd fe ff fg fh"><div class="o u nz"><div class="o ao gk"><div class="oa l"><span class="l gm ob oc e d"><div class="o ao gk"><div class="pw-multi-vote-icon dp od oe of og"><div class=""><div class="ds oh df oi oj ok ol bb om on oo og"><svg width="24" height="24" viewbox="0 0 24 24" aria-label="clap"><path fill-rule="evenodd" clip-rule="evenodd" d="M11.37.83L12 3.28l.63-2.45h-1.26zM15.42 1.84l-1.18-.39-.34 2.5 1.52-2.1zM9.76 1.45l-1.19.4 1.53 2.1-.34-2.5zM20.25 11.84l-2.5-4.4a1.42 1.42 0 0 0-.93-.64.96.96 0 0 0-.75.18c-.25.19-.4.42-.45.7l.05.05 2.35 4.13c1.62 2.95 1.1 5.78-1.52 8.4l-.46.41c1-.13 1.93-.6 2.78-1.45 2.7-2.7 2.51-5.59 1.43-7.38zM12.07 9.01c-.13-.69.08-1.3.57-1.77l-2.06-2.07a1.12 1.12 0 0 0-1.56 0c-.15.15-.22.34-.27.53L12.07 9z"/><path fill-rule="evenodd" clip-rule="evenodd" d="M14.74 8.3a1.13 1.13 0 0 0-.73-.5.67.67 0 0 0-.53.13c-.15.12-.59.46-.2 1.3l1.18 2.5a.45.45 0 0 1-.23.76.44.44 0 0 1-.48-.25L7.6 6.11a.82.82 0 1 0-1.15 1.15l3.64 3.64a.45.45 0 1 1-.63.63L5.83 7.9 4.8 6.86a.82.82 0 0 0-1.33.9c.04.1.1.18.18.26l1.02 1.03 3.65 3.64a.44.44 0 0 1-.15.73.44.44 0 0 1-.48-.1L4.05 9.68a.82.82 0 0 0-1.4.57.81.81 0 0 0 .24.58l1.53 1.54 2.3 2.28a.45.45 0 0 1-.64.63L3.8 13a.81.81 0 0 0-1.39.57c0 .22.09.43.24.58l4.4 4.4c2.8 2.8 5.5 4.12 8.68.94 2.27-2.28 2.71-4.6 1.34-7.1l-2.32-4.08z"/></svg></div></div></div><div class="pw-multi-vote-count l op oq or os ot ou ov"><p class="bn b gq bp co"><span class="oh">--</span></p></div></div></span><span class="l h g f ow ox"><div class="o ao gk"><div class="pw-multi-vote-icon dp od oe of og"><div class=""><div class="ds oh df oi oj ok ol bb om on oo og"><svg width="24" height="24" viewbox="0 0 24 24" aria-label="clap"><path fill-rule="evenodd" clip-rule="evenodd" d="M11.37.83L12 3.28l.63-2.45h-1.26zM15.42 1.84l-1.18-.39-.34 2.5 1.52-2.1zM9.76 1.45l-1.19.4 1.53 2.1-.34-2.5zM20.25 11.84l-2.5-4.4a1.42 1.42 0 0 0-.93-.64.96.96 0 0 0-.75.18c-.25.19-.4.42-.45.7l.05.05 2.35 4.13c1.62 2.95 1.1 5.78-1.52 8.4l-.46.41c1-.13 1.93-.6 2.78-1.45 2.7-2.7 2.51-5.59 1.43-7.38zM12.07 9.01c-.13-.69.08-1.3.57-1.77l-2.06-2.07a1.12 1.12 0 0 0-1.56 0c-.15.15-.22.34-.27.53L12.07 9z"/><path fill-rule="evenodd" clip-rule="evenodd" d="M14.74 8.3a1.13 1.13 0 0 0-.73-.5.67.67 0 0 0-.53.13c-.15.12-.59.46-.2 1.3l1.18 2.5a.45.45 0 0 1-.23.76.44.44 0 0 1-.48-.25L7.6 6.11a.82.82 0 1 0-1.15 1.15l3.64 3.64a.45.45 0 1 1-.63.63L5.83 7.9 4.8 6.86a.82.82 0 0 0-1.33.9c.04.1.1.18.18.26l1.02 1.03 3.65 3.64a.44.44 0 0 1-.15.73.44.44 0 0 1-.48-.1L4.05 9.68a.82.82 0 0 0-1.4.57.81.81 0 0 0 .24.58l1.53 1.54 2.3 2.28a.45.45 0 0 1-.64.63L3.8 13a.81.81 0 0 0-1.39.57c0 .22.09.43.24.58l4.4 4.4c2.8 2.8 5.5 4.12 8.68.94 2.27-2.28 2.71-4.6 1.34-7.1l-2.32-4.08z"/></svg></div></div></div><div class="pw-multi-vote-count l op oq or os ot ou ov"><p class="bn b gq bp co"><span class="oh">--</span></p></div></div></span></div><div class="oy o"><div><div class="cj" aria-hidden="false"><button class="pa ds pb o ao df pc pd" aria-label="responses"><svg width="24" height="24" viewbox="0 0 24 24" aria-label="responses" class="oz"><path d="M18 16.8a7.14 7.14 0 0 0 2.24-5.32c0-4.12-3.53-7.48-8.05-7.48C7.67 4 4 7.36 4 11.48c0 4.13 3.67 7.48 8.2 7.48a8.9 8.9 0 0 0 2.38-.32c.23.2.48.39.75.56 1.06.69 2.2 1.04 3.4 1.04.22 0 .4-.11.48-.29a.5.5 0 0 0-.04-.52 6.4 6.4 0 0 1-1.16-2.65v.02zm-3.12 1.06l-.06-.22-.32.1a8 8 0 0 1-2.3.33c-4.03 0-7.3-2.96-7.3-6.59S8.17 4.9 12.2 4.9c4 0 7.1 2.96 7.1 6.6 0 1.8-.6 3.47-2.02 4.72l-.2.16v.26l.02.3a6.74 6.74 0 0 0 .88 2.4 5.27 5.27 0 0 1-2.17-.86c-.28-.17-.72-.38-.94-.59l.01-.02z"/></svg><p class="bn b bo bp co"><span class="pw-responses-count pe oz pf">5</span></p></button></div></div></div></div><div class="o ao"><div class="cj" aria-hidden="false" aria-describedby="postFooterSocialMenu" aria-labelledby="postFooterSocialMenu"><div><div class="cj" aria-hidden="false"><button class="au av aw ax ay az ba hi bc bd be bf bg bh bi pg hj ph" aria-controls="postFooterSocialMenu" aria-expanded="false" aria-label="Share Post"><svg width="24" height="24" viewbox="0 0 24 24" fill="none"><path fill-rule="evenodd" clip-rule="evenodd" d="M15.22 4.93a.42.42 0 0 1-.12.13h.01a.45.45 0 0 1-.29.08.52.52 0 0 1-.3-.13L12.5 3v7.07a.5.5 0 0 1-.5.5.5.5 0 0 1-.5-.5V3.02l-2 2a.45.45 0 0 1-.57.04h-.02a.4.4 0 0 1-.16-.3.4.4 0 0 1 .1-.32l2.8-2.8a.5.5 0 0 1 .7 0l2.8 2.8a.42.42 0 0 1 .07.5zm-.1.14zm.88 2h1.5a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-11a2 2 0 0 1-2-2v-10a2 2 0 0 1 2-2H8a.5.5 0 0 1 .35.14c.1.1.15.22.15.35a.5.5 0 0 1-.15.35.5.5 0 0 1-.35.15H6.4c-.5 0-.9.4-.9.9v10.2a.9.9 0 0 0 .9.9h11.2c.5 0 .9-.4.9-.9V8.96c0-.5-.4-.9-.9-.9H16a.5.5 0 0 1 0-1z" fill="#000"/></svg></button></div></div></div><div class="pi l hh"></div></div></div></div></div></div></footer></div><div class="o dy"><div class="en cf ez fa fb fc fd fe ff fg fh"></div></div><div class="l"><div class="l pj nz"><div class="l nz"><div class="pk pl l pj"><div class="o dy"><div class="en cf ez fa fb fc fd fe ff fg fh"><div class="o ao u"><h2 class="bn pm ne ng pn ll nh nj po lp ka nl pp lt ke nn pq lx ki np pr mb ps pt pu pv pw px py gi"><a class="au av aw ax ay az ba bb bc bd be bf bg bh bi" rel="noopener follow" href="/@JakobUlbrich?source=post_page-----ac4ec8aee7d1--------------------------------">More from Jakob Ulbrich</a></h2><div class="pz o"><span><button class="bn b bo bp gr br gt gu gv gw gx bd ca gy gz ha ce cg ch ci cj ck">Follow</button></span><div class="pz l"><div><div><div class="cj" aria-hidden="false"><div class="l"><span><a class="au av aw ax ay az ba bb bc bd be bf bg bh bi" rel="noopener follow" href="/m/signin?actionUrl=%2F_%2Fapi%2Fsubscriptions%2Fnewsletters%2Fe6f352cc4e5e&amp;operation=register&amp;redirect=https%3A%2F%2Fmedium.com%2F%40JakobUlbrich%2Fflag-attributes-in-android-how-to-use-them-ac4ec8aee7d1&amp;newsletterV3=73d0266697d8&amp;newsletterV3Id=e6f352cc4e5e&amp;user=Jakob+Ulbrich&amp;userId=73d0266697d8&amp;source=-----ac4ec8aee7d1---------------------subscribe_user-----------"><button class="bn b bo bp bq bb bs bt bu bv bw bx by bz ca gy gz ha ce cg ch ci cj ck" aria-label="Subscribe"><svg width="38" height="38" viewbox="0 0 38 38" fill="none" class="qa qb qc"><rect x="26.25" y="9.25" width="0.5" height="6.5" rx="0.25"/><rect x="29.75" y="12.25" width="0.5" height="6.5" rx="0.25" transform="rotate(90 29.75 12.25)"/><path d="M19.5 12.5h-7a1 1 0 0 0-1 1v11a1 1 0 0 0 1 1h13a1 1 0 0 0 1-1v-5"/><path d="M11.5 14.5L19 20l4-3"/></svg></button></a></span></div></div></div></div></div></div></div></div></div></div></div><div class="qd l"><div class="qe qf qg qh l"><div class="hs l bm"><div class="o dy"><div class="qi qj qk ql qm jn en cf"><div class="ah qn ai qo go qp gp qq ox qr"><p class="bn b dn do gi">Love podcasts or audiobooks? Learn on the go with our new app.</p></div><div class="qs ah qt ai qu go qv gp qw ox"><a class="bn b bo bp gr br gt qx qy qz ra bd ca cb cc cd ce cg ch ci cj ck" href="https://knowable.fyi/?utm_source=medium&amp;utm_medium=referral&amp;utm_campaign=medium-post-footer&amp;source=post_page-----ac4ec8aee7d1--------------------------------" rel="noopener follow">Try Knowable</a></div></div></div></div></div></div><div class="o dy"><div class="en cf ez fa fb fc fd fe ff fg fh"><div class="rb qg l"></div></div></div></div></div><div class="d"><div class="rc rd re l nw ar ee as rf rg"><div class="o dy"><div class="ez fa rh ri rj rk en cf"><a class="au av aw ax ay az ba bb bc bd rl rm bg rn ro" aria-label="Go to homepage" rel="noopener follow" href="/?source=post_page-----ac4ec8aee7d1--------------------------------"><svg viewbox="0 0 3940 610" class="gt rp"><path d="M594.79 308.2c0 163.76-131.85 296.52-294.5 296.52S5.8 472 5.8 308.2 137.65 11.69 300.29 11.69s294.5 132.75 294.5 296.51M917.86 308.2c0 154.16-65.93 279.12-147.25 279.12s-147.25-125-147.25-279.12S689.29 29.08 770.61 29.08s147.25 125 147.25 279.12M1050 308.2c0 138.12-23.19 250.08-51.79 250.08s-51.79-112-51.79-250.08 23.19-250.08 51.8-250.08S1050 170.09 1050 308.2M1862.77 37.4l.82-.18v-6.35h-167.48l-155.51 365.5-155.51-365.5h-180.48v6.35l.81.18c30.57 6.9 46.09 17.19 46.09 54.3v434.45c0 37.11-15.58 47.4-46.15 54.3l-.81.18V587H1327v-6.35l-.81-.18c-30.57-6.9-46.09-17.19-46.09-54.3V116.9L1479.87 587h11.33l205.59-483.21V536.9c-2.62 29.31-18 38.36-45.68 44.61l-.82.19v6.3h213.3v-6.3l-.82-.19c-27.71-6.25-43.46-15.3-46.08-44.61l-.14-445.2h.14c0-37.11 15.52-47.4 46.08-54.3m97.43 287.8c3.49-78.06 31.52-134.4 78.56-135.37 14.51.24 26.68 5 36.14 14.16 20.1 19.51 29.55 60.28 28.09 121.21zm-2.11 22h250v-1.05c-.71-59.69-18-106.12-51.34-138-28.82-27.55-71.49-42.71-116.31-42.71h-1c-23.26 0-51.79 5.64-72.09 15.86-23.11 10.7-43.49 26.7-60.45 47.7-27.3 33.83-43.84 79.55-47.86 130.93-.13 1.54-.24 3.08-.35 4.62s-.18 2.92-.25 4.39a332.64 332.64 0 0 0-.36 21.69C1860.79 507 1923.65 600 2035.3 600c98 0 155.07-71.64 169.3-167.8l-7.19-2.53c-25 51.68-69.9 83-121 79.18-69.76-5.22-123.2-75.95-118.35-161.63m532.69 157.68c-8.2 19.45-25.31 30.15-48.24 30.15s-43.89-15.74-58.78-44.34c-16-30.7-24.42-74.1-24.42-125.51 0-107 33.28-176.21 84.79-176.21 21.57 0 38.55 10.7 46.65 29.37zm165.84 76.28c-30.57-7.23-46.09-18-46.09-57V5.28L2424.77 60v6.7l1.14-.09c25.62-2.07 43 1.47 53.09 10.79 7.9 7.3 11.75 18.5 11.75 34.26v71.14c-18.31-11.69-40.09-17.38-66.52-17.38-53.6 0-102.59 22.57-137.92 63.56-36.83 42.72-56.3 101.1-56.3 168.81C2230 518.72 2289.53 600 2378.13 600c51.83 0 93.53-28.4 112.62-76.3V588h166.65v-6.66zm159.29-505.33c0-37.76-28.47-66.24-66.24-66.24-37.59 0-67 29.1-67 66.24s29.44 66.24 67 66.24c37.77 0 66.24-28.48 66.24-66.24m43.84 505.33c-30.57-7.23-46.09-18-46.09-57h-.13V166.65l-166.66 47.85v6.5l1 .09c36.06 3.21 45.93 15.63 45.93 57.77V588h166.8v-6.66zm427.05 0c-30.57-7.23-46.09-18-46.09-57V166.65L3082 212.92v6.52l.94.1c29.48 3.1 38 16.23 38 58.56v226c-9.83 19.45-28.27 31-50.61 31.78-36.23 0-56.18-24.47-56.18-68.9V166.66l-166.66 47.85V221l1 .09c36.06 3.2 45.94 15.62 45.94 57.77v191.27a214.48 214.48 0 0 0 3.47 39.82l3 13.05c14.11 50.56 51.08 77 109 77 49.06 0 92.06-30.37 111-77.89v66h166.66v-6.66zM3934.2 588v-6.67l-.81-.19c-33.17-7.65-46.09-22.07-46.09-51.43v-243.2c0-75.83-42.59-121.09-113.93-121.09-52 0-95.85 30.05-112.73 76.86-13.41-49.6-52-76.86-109.06-76.86-50.12 0-89.4 26.45-106.25 71.13v-69.87l-166.66 45.89v6.54l1 .09c35.63 3.16 45.93 15.94 45.93 57V588h155.5v-6.66l-.82-.2c-26.46-6.22-35-17.56-35-46.66V255.72c7-16.35 21.11-35.72 49-35.72 34.64 0 52.2 24 52.2 71.28V588h155.54v-6.66l-.82-.2c-26.46-6.22-35-17.56-35-46.66v-248a160.45 160.45 0 0 0-2.2-27.68c7.42-17.77 22.34-38.8 51.37-38.8 35.13 0 52.2 23.31 52.2 71.28V588z"/></svg></a><div class="rq l"><p class="bn b gq bp rr"><a class="au av aw ax ay az ba bb bc bd rs bg rn ro lf" href="https://medium.com/about?autoplay=1&amp;source=post_page-----ac4ec8aee7d1--------------------------------" rel="noopener follow">About</a><a class="au av aw ax ay az ba bb bc bd rs bg rn ro lf" href="https://help.medium.com/hc/en-us?source=post_page-----ac4ec8aee7d1--------------------------------" rel="noopener follow">Help</a><a class="au av aw ax ay az ba bb bc bd rs bg rn ro lf" href="https://policy.medium.com/medium-terms-of-service-9db0094a1e0f?source=post_page-----ac4ec8aee7d1--------------------------------" rel="noopener follow">Terms</a><a class="au av aw ax ay az ba bb bc bd rs bg rn ro" href="https://policy.medium.com/medium-privacy-policy-f03bf92035c9?source=post_page-----ac4ec8aee7d1--------------------------------" rel="noopener follow">Privacy</a></p></div><div class="j i d"><hr class="ds dt rt ru" aria-hidden="true"><h2 class="bn pm dn bp ig rr">Get the Medium app</h2><div class="rq o"><div class="gb l"><a class="au av aw ax ay az ba bb bc bd rl rm bg rn ro" href="https://itunes.apple.com/app/medium-everyones-stories/id828256236?pt=698524&amp;mt=8&amp;ct=post_page&amp;source=post_page-----ac4ec8aee7d1--------------------------------" rel="noopener follow"><img alt="A button that says &apos;Download on the App Store&apos;, and if clicked it will lead you to the iOS App store" class="" src="https://miro.medium.com/max/270/1*Crl55Tm6yDNMoucPo1tvDg.png" width="135" height="41"></a></div><a class="au av aw ax ay az ba bb bc bd rl rm bg rn ro" href="https://play.google.com/store/apps/details?id=com.medium.reader&amp;source=post_page-----ac4ec8aee7d1--------------------------------" rel="noopener follow"><img alt="A button that says &apos;Get it on, Google Play&apos;, and if clicked it will lead you to the Google Play store" class="" src="https://miro.medium.com/max/270/1*W_RAPQ62h0em559zluJLdQ.png" width="135" height="41"></a></div></div></div></div></div></div></div></main><div class="ep ci c eq h k j i cv er es et"><div class="ag cf cj dp"><div class="l dc aq"><div class="er o db"><div class="l ny"><div class="l c"><div class="l"><div class="qg o ao"><div class="pw-susi-button l ny"><span><a class="au av aw ax ay az ba bb bc bd be bf bg bh bi" rel="noopener follow" href="/m/signin?operation=register&amp;redirect=https%3A%2F%2Fmedium.com%2F%40JakobUlbrich%2Fflag-attributes-in-android-how-to-use-them-ac4ec8aee7d1&amp;source=post_page--------------------------nav_reg-----------"><button class="bn b bo bp bq br bs bt bu bv bw bx by bz ca cb cc cd ce cf cg ch ci cj ck" aria-label="sign up">Get started</button></a></span></div></div></div><div class="rv l"><div class="o hr rw rx"><div class="cj" aria-hidden="false" aria-describedby="searchResults" aria-labelledby="searchResults"></div><span class="sc l"><svg width="25" height="25" viewbox="0 0 25 25" fill="rgba(8, 8, 8, 1)"><path d="M20.07 18.93l-4.16-4.15a6 6 0 1 0-.88.88l4.15 4.16a.62.62 0 1 0 .89-.89zM6.5 11a4.75 4.75 0 1 1 9.5 0 4.75 4.75 0 0 1-9.5 0z"/></svg></span><input role="combobox" aria-controls="searchResults" aria-expanded="false" aria-label="search" tabindex="0" class="ea ry bn bo bp lf cf rz sa gi sb" placeholder="Search" value=""></div><div class="sd l"></div><a class="au av aw ax ay az ba bb bc bd be bf bg bh bi" rel="noopener follow" href="/@JakobUlbrich"><div class="l dp"><img alt="Jakob Ulbrich" class="l ci gd se sf gh" src="https://miro.medium.com/fit/c/176/176/1*bkOovjlNjFTpGC0wTuyMCQ.jpeg" width="88" height="88"><div class="gc gd l se sf gg aq"></div></div></a><div class="sg l"></div><a class="au av aw ax ay az ba bb bc bd be bf bg bh bi" rel="noopener follow" href="/@JakobUlbrich"><h2 class="pw-author-name bn pm dn bp ig gi">Jakob Ulbrich</h2></a><div class="sh l"></div><span class="pw-follower-count bn b dn do co"><button class="au av aw ax ay az ba bb bc bd be bf bg bh bi">506 Followers</button></span><div class="si l"></div><div class="sj l"></div><div class="sk o"><span><button class="bn b bo bp gr br gt gu gv gw gx bd ca gy gz ha ce sl cg ch ci cj ck">Follow</button></span><div class="pz l"><div><div><div class="cj" aria-hidden="false"><div class="l"><span><a class="au av aw ax ay az ba bb bc bd be bf bg bh bi" rel="noopener follow" href="/m/signin?actionUrl=%2F_%2Fapi%2Fsubscriptions%2Fnewsletters%2Fe6f352cc4e5e&amp;operation=register&amp;redirect=https%3A%2F%2Fmedium.com%2F%40JakobUlbrich%2Fflag-attributes-in-android-how-to-use-them-ac4ec8aee7d1&amp;newsletterV3=73d0266697d8&amp;newsletterV3Id=e6f352cc4e5e&amp;user=Jakob+Ulbrich&amp;userId=73d0266697d8&amp;source=--------------------------subscribe_user-----------"><button class="bn b bo bp bq bb bs bt bu bv bw bx by bz ca gy gz ha ce cg ch ci cj ck" aria-label="Subscribe"><svg width="38" height="38" viewbox="0 0 38 38" fill="none" class="qa qb qc"><rect x="26.25" y="9.25" width="0.5" height="6.5" rx="0.25"/><rect x="29.75" y="12.25" width="0.5" height="6.5" rx="0.25" transform="rotate(90 29.75 12.25)"/><path d="M19.5 12.5h-7a1 1 0 0 0-1 1v11a1 1 0 0 0 1 1h13a1 1 0 0 0 1-1v-5"/><path d="M11.5 14.5L19 20l4-3"/></svg></button></a></span></div></div></div></div></div></div><div class="kz l"><div class="l"><div class="sm sd l"><h2 class="bn pm dn bp ig gi">More from Medium</h2></div><div class="l"><div class="cf ag"><div class="sm o db dy"><div class="o gk u"><div class="sn o db so"><div class="sp o ao"><div class="sq l"><a class="au av aw ax ay az ba bb bc bd be bf bg bh bi" rel="noopener follow" href="/@wanxiao1994?source=read_next_recirc---------0---------------------77d58d3d_d321_4d2e_87e2_b5097aab16e7-------"><div class="l dp"><img alt="Wan Xiao" class="l ci gd sr ss gh" src="https://miro.medium.com/fit/c/40/40/0*qNpEYNzHlQ6SH6Z5" width="20" height="20"><div class="gc gd l sr ss gg aq"></div></div></a></div><div class="hg l"><div><div class="cj" aria-hidden="false"><div class="o"><a class="au av aw ax ay az ba bb bc bd be bf bg bh bi" rel="noopener follow" href="/@wanxiao1994?source=read_next_recirc---------0---------------------77d58d3d_d321_4d2e_87e2_b5097aab16e7-------"><p class="bn b gq bp ps st pt pu pv pw px py gi">Wan Xiao</p></a></div></div></div></div></div><a rel="noopener follow" href="/@wanxiao1994/why-resizable-bitmap-created-by-android-studio-is-distorted-2c3a96877ed0?source=read_next_recirc---------0---------------------77d58d3d_d321_4d2e_87e2_b5097aab16e7-------"><h2 class="bn ii dn bp ps su pt pu sv pw py ig gi"><div>Why resizable bitmap created by Android Studio is distorted</div></h2></a></div><a rel="noopener follow" href="/@wanxiao1994/why-resizable-bitmap-created-by-android-studio-is-distorted-2c3a96877ed0?source=read_next_recirc---------0---------------------77d58d3d_d321_4d2e_87e2_b5097aab16e7-------"><div class="sw l"></div></a></div></div></div><div class="cf ag"><div class="sm o db dy"><div class="o gk u"><div class="sn o db so"><div class="sp o ao"><div class="sq l"><a class="au av aw ax ay az ba bb bc bd be bf bg bh bi" rel="noopener follow" href="/@lubnamariyam62?source=read_next_recirc---------1---------------------77d58d3d_d321_4d2e_87e2_b5097aab16e7-------"><div class="l dp"><img alt="Lubnamariyam" class="l ci gd sr ss gh" src="https://miro.medium.com/fit/c/40/40/1*Q8SvMovsVGM-TUZoQKPSUA.jpeg" width="20" height="20"><div class="gc gd l sr ss gg aq"></div></div></a></div><div class="hg l"><div><div class="cj" aria-hidden="false"><div class="o"><a class="au av aw ax ay az ba bb bc bd be bf bg bh bi" rel="noopener follow" href="/@lubnamariyam62?source=read_next_recirc---------1---------------------77d58d3d_d321_4d2e_87e2_b5097aab16e7-------"><p class="bn b gq bp ps st pt pu pv pw px py gi">Lubnamariyam</p></a></div></div></div></div></div><a rel="noopener follow" href="/@lubnamariyam62/android-jetpack-compose-basics-text-c0a8cffa1b6f?source=read_next_recirc---------1---------------------77d58d3d_d321_4d2e_87e2_b5097aab16e7-------"><h2 class="bn ii dn bp ps su pt pu sv pw py ig gi"><div>Android Jetpack Compose Basics&#x200A;&#x2014;&#x200A;Text</div></h2></a></div><a rel="noopener follow" href="/@lubnamariyam62/android-jetpack-compose-basics-text-c0a8cffa1b6f?source=read_next_recirc---------1---------------------77d58d3d_d321_4d2e_87e2_b5097aab16e7-------"><div class="sw l"><div class="m l dp gh"><div class="sx sy l"><img alt="" class="sz" src="https://miro.medium.com/focal/112/112/50/50/1*OJnm2S-vVuiGp1gi2I83sg.png" width="56" role="presentation"></div></div></div></a></div></div></div><div class="cf ag"><div class="sm o db dy"><div class="o gk u"><div class="sn o db so"><div class="sp o ao"><div class="sq l"><a class="au av aw ax ay az ba bb bc bd be bf bg bh bi" rel="noopener follow" href="/@leonidosmakolkin?source=read_next_recirc---------2---------------------77d58d3d_d321_4d2e_87e2_b5097aab16e7-------"><div class="l dp"><img alt="Leonidos Makolkin" class="l ci gd sr ss gh" src="https://miro.medium.com/fit/c/40/40/0*h9GVIOdO7IzBkWDW" width="20" height="20"><div class="gc gd l sr ss gg aq"></div></div></a></div><div class="hg l"><div><div class="cj" aria-hidden="false"><div class="o"><a class="au av aw ax ay az ba bb bc bd be bf bg bh bi" rel="noopener follow" href="/@leonidosmakolkin?source=read_next_recirc---------2---------------------77d58d3d_d321_4d2e_87e2_b5097aab16e7-------"><p class="bn b gq bp ps st pt pu pv pw px py gi">Leonidos Makolkin</p></a></div></div></div></div></div><a rel="noopener follow" href="/@leonidosmakolkin/everyone-can-make-custom-android-gradle-tasks-91b52e10cc8f?source=read_next_recirc---------2---------------------77d58d3d_d321_4d2e_87e2_b5097aab16e7-------"><h2 class="bn ii dn bp ps su pt pu sv pw py ig gi"><div>Everyone can make Custom Android Gradle tasks</div></h2></a></div><a rel="noopener follow" href="/@leonidosmakolkin/everyone-can-make-custom-android-gradle-tasks-91b52e10cc8f?source=read_next_recirc---------2---------------------77d58d3d_d321_4d2e_87e2_b5097aab16e7-------"><div class="sw l"><div class="m l dp gh"><div class="sx sy l"><img alt="" class="sz" src="https://miro.medium.com/focal/112/112/50/50/1*837xmcVEM1ghuAMcdoowSQ.png" width="56" role="presentation"></div></div></div></a></div></div></div><div class="cf ag"><div class="sm o db dy"><div class="o gk u"><div class="sn o db so"><div class="sp o ao"><div class="sq l"><a class="au av aw ax ay az ba bb bc bd be bf bg bh bi" rel="noopener follow" href="/@aomekkla?source=read_next_recirc---------3---------------------77d58d3d_d321_4d2e_87e2_b5097aab16e7-------"><div class="l dp"><img alt="warunee khammak" class="l ci gd sr ss gh" src="https://miro.medium.com/fit/c/40/40/1*eCLQFWsumzVVdo_5HP2dvg.jpeg" width="20" height="20"><div class="gc gd l sr ss gg aq"></div></div></a></div><div class="hg l"><div><div class="cj" aria-hidden="false"><div class="o"><a class="au av aw ax ay az ba bb bc bd be bf bg bh bi" rel="noopener follow" href="/@aomekkla?source=read_next_recirc---------3---------------------77d58d3d_d321_4d2e_87e2_b5097aab16e7-------"><p class="bn b gq bp ps st pt pu pv pw px py gi">warunee khammak</p></a></div></div></div></div></div><a rel="noopener follow" href="/@aomekkla/add-spacing-at-the-start-and-the-end-of-list-with-itemdecoration-26b6c41be5b9?source=read_next_recirc---------3---------------------77d58d3d_d321_4d2e_87e2_b5097aab16e7-------"><h2 class="bn ii dn bp ps su pt pu sv pw py ig gi"><div>Add spacing at the start and the end of list with ItemDecoration</div></h2></a></div><a rel="noopener follow" href="/@aomekkla/add-spacing-at-the-start-and-the-end-of-list-with-itemdecoration-26b6c41be5b9?source=read_next_recirc---------3---------------------77d58d3d_d321_4d2e_87e2_b5097aab16e7-------"><div class="sw l"></div></a></div></div></div></div></div></div></div></div></div><div class="ta o gk hb"><div class="tb l"><a class="au av aw ax ay az ba bb bc bd be bf bg bh bi" href="https://help.medium.com/hc/en-us" rel="noopener follow"><p class="bn b tc td co">Help</p></a></div><div class="tb l"><a class="au av aw ax ay az ba bb bc bd be bf bg bh bi" href="https://medium.statuspage.io" rel="noopener follow"><p class="bn b tc td co">Status</p></a></div><div class="tb l"><a class="au av aw ax ay az ba bb bc bd be bf bg bh bi" href="https://about.medium.com/creators/" rel="noopener follow"><p class="bn b tc td co">Writers</p></a></div><div class="tb l"><a class="au av aw ax ay az ba bb bc bd be bf bg bh bi" href="https://blog.medium.com" rel="noopener follow"><p class="bn b tc td co">Blog</p></a></div><div class="tb l"><a class="au av aw ax ay az ba bb bc bd be bf bg bh bi" rel="noopener follow" href="/jobs-at-medium/work-at-medium-959d1a85284e"><p class="bn b tc td co">Careers</p></a></div><div class="tb l"><a class="au av aw ax ay az ba bb bc bd be bf bg bh bi" href="https://policy.medium.com/medium-privacy-policy-f03bf92035c9" rel="noopener follow"><p class="bn b tc td co">Privacy</p></a></div><div class="tb l"><a class="au av aw ax ay az ba bb bc bd be bf bg bh bi" href="https://policy.medium.com/medium-terms-of-service-9db0094a1e0f" rel="noopener follow"><p class="bn b tc td co">Terms</p></a></div><div class="tb l"><a class="au av aw ax ay az ba bb bc bd be bf bg bh bi" href="https://medium.com/about?autoplay=1" rel="noopener follow"><p class="bn b tc td co">About</p></a></div><div class="tb l"><a class="au av aw ax ay az ba bb bc bd be bf bg bh bi" href="https://knowable.fyi" rel="noopener follow"><p class="bn b tc td co">Knowable</p></a></div></div></div></div></div></div></div></div></div></div></div>
</body></html>