{"id":2887,"date":"2012-11-30T14:17:52","date_gmt":"2012-11-30T14:17:52","guid":{"rendered":"http:\/\/www.gubatron.com\/blog\/?p=2887"},"modified":"2012-11-30T14:17:52","modified_gmt":"2012-11-30T14:17:52","slug":"android-changing-textview-alpha-transparency-across-different-target-sdks","status":"publish","type":"post","link":"https:\/\/www.gubatron.com\/blog\/android-changing-textview-alpha-transparency-across-different-target-sdks\/","title":{"rendered":"Android: Changing TextView alpha transparency across different target SDKs"},"content":{"rendered":"<p>Sometimes you may need to make a TextView (label) look a little transparent to make emphasis on other parts of your UI. The .setAlpha() function on TextView is not supported after later in the SDK. Here&#8217;s a static workaround you can place on some sort of UIUtils class you may have in your project.<\/p>\n<p>[java]<br \/>\n    \/**<br \/>\n     * Android devices with SDK below target=11 do not support textView.setAlpha().<br \/>\n     * This is a work around.<br \/>\n     * @param v &#8211; the text view<br \/>\n     * @param alpha &#8211; a value from 0 to 255. (0=transparent, 255=fully visible)<br \/>\n     *\/<br \/>\n    public static void setTextViewAlpha(TextView v, int alpha) {<br \/>\n        v.setTextColor(v.getTextColors().withAlpha(alpha));<br \/>\n        v.setHintTextColor(v.getHintTextColors().withAlpha(alpha));<br \/>\n        v.setLinkTextColor(v.getLinkTextColors().withAlpha(alpha));<\/p>\n<p>        Drawable[] compoundDrawables = v.getCompoundDrawables();<br \/>\n        for (int i=0 ; i < compoundDrawables.length; i++) {\n            Drawable d = compoundDrawables[i];\n            if (d != null) {\n                d.setAlpha(alpha);\n            }\n        }\n        \n    }\n[\/java]\n\nEnjoy, and above all\nCODE!\n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you may need to make a TextView (label) look a little transparent to make emphasis on other parts of your UI. The .setAlpha() function on TextView is not supported after later in the SDK. Here&#8217;s a static workaround you can place on some sort of UIUtils class you may have in your project. [java] [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[1434,1437,1203,583],"class_list":["post-2887","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-android","tag-code","tag-fragmentation","tag-java"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5Unzf-Kz","jetpack-related-posts":[{"id":1814,"url":"https:\/\/www.gubatron.com\/blog\/android-making-a-textview-scrollable\/","url_meta":{"origin":2887,"position":0},"title":"Android: Making a TextView Scrollable","author":"gubatron","date":"April 19, 2010","format":false,"excerpt":"I needed a TextView to take the rest of the screen realstate. This TextView would behave as a logging component. I tried using android:singleLine=\"false\" but that didn't cut it. What I did: Add a ScrollView (with android:fillViewport=\"true\" and android:layout_weight=\"1\"), then add a LinearLayout (yup...), and then add the TextView to\u2026","rel":"","context":"In &quot;Android&quot;","block_context":{"text":"Android","link":"https:\/\/www.gubatron.com\/blog\/category\/android\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3616,"url":"https:\/\/www.gubatron.com\/blog\/codejava-argb_8888-pixel-abstraction\/","url_meta":{"origin":2887,"position":1},"title":"[CODE\/JAVA] ARGB_8888 Pixel Abstraction","author":"gubatron","date":"December 4, 2016","format":false,"excerpt":"This is one of the ways you can decode Pixel colors out of the integers you get from Android Pixels. ARGB_8888, stands for Alpha, Reg, Green, Blue. The 8's stand for the number of bits per channel. In Android, signed int's are used to represent pixel's alpha\/color information. Since Android's\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2941,"url":"https:\/\/www.gubatron.com\/blog\/java-how-to-get-all-the-files-inside-a-folder-and-its-subfolders-without-recursion\/","url_meta":{"origin":2887,"position":2},"title":"java: How to get all the files inside a folder and its subfolders without recursion","author":"gubatron","date":"March 19, 2013","format":false,"excerpt":"Most programmers will do this in a recursive fashion, but doing that is putting yourself at risk of hitting a stack overflow error, and it's 20% slower (according to my tests). Here's my first implementation of a method that will return just the files (cause I didn't need the folders,\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2138,"url":"https:\/\/www.gubatron.com\/blog\/java-how-to-create-dynamic-pngs-jpgs-gifs\/","url_meta":{"origin":2887,"position":3},"title":"Java: How to create dynamic PNGs, JPGs, GIFs.","author":"gubatron","date":"February 14, 2010","format":false,"excerpt":"Sometimes you need to create graphics, or compose images and have them saved as regular PNGs, JPEGs or GIFs. Here's a quick and dirty reference of how to do it with BufferedImages, Graphics2D and javax.imageio.*. Very straightforward. [java] import java.awt.Color; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO;\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":239,"url":"https:\/\/www.gubatron.com\/blog\/ubunteros-check-this-out\/","url_meta":{"origin":2887,"position":4},"title":"Ubunteros, Check this out","author":"gubatron","date":"January 18, 2006","format":false,"excerpt":"Dapper Flight3 CD is out (warning: try at your own risk - this is an alpha release - not meant for production machines)","rel":"","context":"In &quot;Gubatron&quot;","block_context":{"text":"Gubatron","link":"https:\/\/www.gubatron.com\/blog\/category\/gubatron\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3020,"url":"https:\/\/www.gubatron.com\/blog\/how-to-avoid-android-compilationbuilding-issues-setting-up-the-eclipse-buildpath-correctly\/","url_meta":{"origin":2887,"position":5},"title":"How to avoid Android compilation\/building issues &#8211; Setting up the Eclipse Buildpath correctly","author":"gubatron","date":"May 21, 2013","format":false,"excerpt":"This post is the product of about 48 hours of not being able to work on what I was supposed to be working because I had to deal with build issues in Eclipse. Hopefully If you follow these steps you will be able to solve some of the issues you\u2026","rel":"","context":"In &quot;Android&quot;","block_context":{"text":"Android","link":"https:\/\/www.gubatron.com\/blog\/category\/android\/"},"img":{"alt_text":"Screen Shot 2013-05-21 at 12.13.46 PM","src":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2013\/05\/Screen-Shot-2013-05-21-at-12.13.46-PM.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2013\/05\/Screen-Shot-2013-05-21-at-12.13.46-PM.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2013\/05\/Screen-Shot-2013-05-21-at-12.13.46-PM.png?resize=525%2C300 1.5x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/2887","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/comments?post=2887"}],"version-history":[{"count":1,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/2887\/revisions"}],"predecessor-version":[{"id":2899,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/2887\/revisions\/2899"}],"wp:attachment":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/media?parent=2887"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/categories?post=2887"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/tags?post=2887"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}