<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Michael Pardo</title>
	<atom:link href="http://www.michaelpardo.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.michaelpardo.com</link>
	<description>Code Snippets from an Android Pro</description>
	<lastBuildDate>Thu, 26 Jan 2012 17:58:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>New app RingDimmer released</title>
		<link>http://www.michaelpardo.com/2012/01/new-app-ringdimmer-released/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=new-app-ringdimmer-released</link>
		<comments>http://www.michaelpardo.com/2012/01/new-app-ringdimmer-released/#comments</comments>
		<pubDate>Thu, 26 Jan 2012 17:58:46 +0000</pubDate>
		<dc:creator>Michael Pardo</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://www.michaelpardo.com/?p=93</guid>
		<description><![CDATA[I&#8217;ve just released a new app for Android that adjust the ringtone and notification volume based on ambient noise. The app is available on the Android Market for $0.99. Check it out on the Android Market or the RingDimmer homepage!]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just released a new app for Android that adjust the ringtone and notification volume based on ambient noise. The app is available on the Android Market for $0.99. Check it out on the <a title="RingDimmer - Android Market" href="https://market.android.com/details?id=com.michaelpardo.ringdimmer">Android Market</a> or the <a title="RingDimmer" href="http://www.ringdimmer.com">RingDimmer homepage</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.michaelpardo.com/2012/01/new-app-ringdimmer-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android Protips Talk Slides</title>
		<link>http://www.michaelpardo.com/2012/01/android-protips-talk-slides/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=android-protips-talk-slides</link>
		<comments>http://www.michaelpardo.com/2012/01/android-protips-talk-slides/#comments</comments>
		<pubDate>Mon, 23 Jan 2012 21:23:51 +0000</pubDate>
		<dc:creator>Michael Pardo</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://www.michaelpardo.com/?p=89</guid>
		<description><![CDATA[I recently gave a talk on Android at CodeMash called Android Protips. I&#8217;ll be giving this talk a few more times this year. I&#8217;ll be at Code PaLOUsa on March 16th, and AnDevCon III on May 14th-17th. If you can&#8217;t make any of those dates, or you &#8230; <a href="http://www.michaelpardo.com/2012/01/android-protips-talk-slides/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I recently gave a talk on Android at <a title="CodeMash" href="http://codemash.org" target="_blank">CodeMash</a> called <a title="CodeMash - Android Protips" href="http://codemash.org/Sessions#Android+Pro+Tips" target="_blank">Android Protips</a>. I&#8217;ll be giving this talk a few more times this year. I&#8217;ll be at <a title="Code PaLOUsa" href="http://www.codepalousa.com/" target="_blank">Code PaLOUsa</a> on March 16th, and <a title="AnDevCon III" href="http://www.andevcon.com/AndevCon_III/index.html" target="_blank">AnDevCon III</a> on May 14th-17th.</p>
<p>If you can&#8217;t make any of those dates, or you just want the slides, you can <a title="Android Protips Slides" href="http://www.michaelpardo.com/files/android_protips.pdf" target="_blank">grab them here</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.michaelpardo.com/2012/01/android-protips-talk-slides/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Falling back on old SDK methods without reflection</title>
		<link>http://www.michaelpardo.com/2011/10/falling-back-on-old-sdk-methods-without-reflection/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=falling-back-on-old-sdk-methods-without-reflection</link>
		<comments>http://www.michaelpardo.com/2011/10/falling-back-on-old-sdk-methods-without-reflection/#comments</comments>
		<pubDate>Fri, 28 Oct 2011 22:50:41 +0000</pubDate>
		<dc:creator>Michael Pardo</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://www.michaelpardo.com/?p=64</guid>
		<description><![CDATA[As Android progresses as a platform, there will inevitably be methods added to the SDK. You&#8217;ll want to add some of these great new features while still supporting the old SDKs. We can conditionally use these methods by getting the device&#8217;s SDK &#8230; <a href="http://www.michaelpardo.com/2011/10/falling-back-on-old-sdk-methods-without-reflection/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>As Android progresses as a platform, there will inevitably be methods added to the SDK. You&#8217;ll want to add some of these great new features while still supporting the old SDKs.</p>
<p>We can conditionally use these methods by getting the device&#8217;s SDK version and using the appropriate method, but this won&#8217;t actually work because although it may compile, the older device will throw an exception when it loads the class that uses that unknown method.</p>
<p>One way to fix this is via reflection, which works great. Reflection, however, can be resource intensive, and hard to maintain. You&#8217;ll have to declare the method as a string and pass in a method signature&#8230; gross.</p>
<p>Another way to do this builds on the first approach. Since a method isn&#8217;t loaded until the class it&#8217;s in is loaded, we can hide the method in another class. Here&#8217;s how it works:</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyActivity <span style="color: #000000; font-weight: bold;">extends</span> ListActivity <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onCreate<span style="color: #009900;">&#40;</span>Bundle savedInstanceState<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onCreate</span><span style="color: #009900;">&#40;</span>savedInstanceState<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; setContentView<span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">layout</span>.<span style="color: #006633;">main</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Check to see if this version of Android supports</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// ListView smooth scrolling</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ainteger+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Integer</span></a>.<span style="color: #006633;">parseInt</span><span style="color: #009900;">&#40;</span>Build.<span style="color: #006633;">VERSION</span>.<span style="color: #006633;">SDK</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;=</span> <span style="color: #cc66cc;">8</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Smooth scroll to position</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SmoothScrollMethodHolder.<span style="color: #006633;">smoothScrollToPosition</span><span style="color: #009900;">&#40;</span>getListView<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Set postion</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; getListView<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setSelection</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">class</span> SmoothScrollMethodHolder <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Put method in a static method of a private class. This class</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// won't be loaded until you call this statically method.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> smoothScrollToPosition<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Alistview+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">ListView</span></a> listView, <span style="color: #000066; font-weight: bold;">int</span> position<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; listView.<span style="color: #006633;">smoothScrollToPosition</span><span style="color: #009900;">&#40;</span>position<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>This code is easy to read, easy to maintain, and comes with all the benefits that reflection strips away, like code completion. Of course, you don&#8217;t want to litter your code with the above, so you&#8217;ll probably want to put it into a utility class.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">class</span> CompatibilityUtils <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">int</span> SDK_VERSION <span style="color: #339933;">=</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ainteger+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Integer</span></a>.<span style="color: #006633;">parseInt</span><span style="color: #009900;">&#40;</span>Build.<span style="color: #006633;">VERSION</span>.<span style="color: #006633;">SDK</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> smoothScrollToPosition<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Alistview+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">ListView</span></a> listView, <span style="color: #000066; font-weight: bold;">int</span> position<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>SDK_VERSION <span style="color: #339933;">&gt;=</span> <span style="color: #cc66cc;">8</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; API9.<span style="color: #006633;">smoothScrollToPosition</span><span style="color: #009900;">&#40;</span>listView, position<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; listView.<span style="color: #006633;">setPosition</span><span style="color: #009900;">&#40;</span>position<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">class</span> API6 <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; ...<br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">class</span> API8 <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> smoothScrollToPosition<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Alistview+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">ListView</span></a> listView, <span style="color: #000066; font-weight: bold;">int</span> position<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; listView.<span style="color: #006633;">smoothScrollToPosition</span><span style="color: #009900;">&#40;</span>position<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">class</span> API9 <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; ...<br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">class</span> API10 <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; ...<br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">class</span> API14 <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; ...<br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>You can add all your compatibility methods to this class. The original code is now just:</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">CompatibilityUtils.<span style="color: #006633;">smoothScrollToPosition</span><span style="color: #009900;">&#40;</span>getListView<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.michaelpardo.com/2011/10/falling-back-on-old-sdk-methods-without-reflection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Inset TextView shadows</title>
		<link>http://www.michaelpardo.com/2011/10/inset-textview-shadows/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=inset-textview-shadows</link>
		<comments>http://www.michaelpardo.com/2011/10/inset-textview-shadows/#comments</comments>
		<pubDate>Mon, 17 Oct 2011 17:48:32 +0000</pubDate>
		<dc:creator>Michael Pardo</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://www.michaelpardo.com/?p=43</guid>
		<description><![CDATA[If you&#8217;re used to using Apple products, you&#8217;re probably familiar with the heavy use of inset shadows. It adds a bit of depth to the UI and can really make the screen look beautiful. Notice the white drop shadow in &#8230; <a href="http://www.michaelpardo.com/2011/10/inset-textview-shadows/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re used to using Apple products, you&#8217;re probably familiar with the heavy use of inset shadows. It adds a bit of depth to the UI and can really make the screen look beautiful. Notice the white drop shadow in the title of the window.</p>
<p style="text-align: center;"><img class="size-full wp-image-44 aligncenter" title="Finder" src="http://www.michaelpardo.com/wp-content/uploads/2011/10/Screen-Shot-2011-10-17-at-1.31.34-PM.png" alt="Finder" width="707" height="463" /></p>
<p>I tend to do the same thing a lot for my Android apps. It&#8217;s incredibly simple to do. Here&#8217;s an example of a TextView with the same inset shadow.</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">&lt;!-- Semi-opaque white inset shadow beneath the text --&gt;</span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextView</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; <span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;wrap_content&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; <span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;wrap_content&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; ...</span><br />
<span style="color: #009900;">&nbsp; &nbsp; <span style="color: #000066;">android:shadowColor</span>=<span style="color: #ff0000;">&quot;#88FFFFFF&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; <span style="color: #000066;">android:shadowRadius</span>=<span style="color: #ff0000;">&quot;0.1&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; <span style="color: #000066;">android:shadowDx</span>=<span style="color: #ff0000;">&quot;0&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; <span style="color: #000066;">android:shadowDy</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: #808080; font-style: italic;">&lt;!-- Semi-opaque black inset shadow above the text --&gt;</span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextView</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; <span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;wrap_content&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; <span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;wrap_content&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; ...</span><br />
<span style="color: #009900;">&nbsp; &nbsp; <span style="color: #000066;">android:shadowColor</span>=<span style="color: #ff0000;">&quot;#88000000&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; <span style="color: #000066;">android:shadowRadius</span>=<span style="color: #ff0000;">&quot;0.1&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; <span style="color: #000066;">android:shadowDx</span>=<span style="color: #ff0000;">&quot;0&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; <span style="color: #000066;">android:shadowDy</span>=<span style="color: #ff0000;">&quot;-1&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></div></div>
<p>And here&#8217;s how it looks:</p>
<p style="text-align: center;"><img class="size-full wp-image-57 aligncenter" title="Inset shadows" src="http://www.michaelpardo.com/wp-content/uploads/2011/10/device-2011-10-18-143333.png" alt="Inset shadows" width="480" height="300" /></p>
<p>It should look great on all screen sizes. Don&#8217;t use the above code strictly, however. Mess around with the color values and shadowRadius value to get the exact effect you&#8217;re looking for.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.michaelpardo.com/2011/10/inset-textview-shadows/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Repeating Bitmaps inside LayerLists</title>
		<link>http://www.michaelpardo.com/2011/10/repeating-bitmaps-inside-layerlists/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=repeating-bitmaps-inside-layerlists</link>
		<comments>http://www.michaelpardo.com/2011/10/repeating-bitmaps-inside-layerlists/#comments</comments>
		<pubDate>Sat, 15 Oct 2011 18:44:32 +0000</pubDate>
		<dc:creator>Michael Pardo</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://blog.michaelpardo.com/?p=37</guid>
		<description><![CDATA[I&#8217;ve run into this particular issue several times now. It&#8217;s a bug in the Android SDK, which apparently has been fixed as of ICS (Ice Cream Sandwich). When you place a &#60;bitmap&#62; inside a &#60;layer-list&#62;, it tends to do whatever &#8230; <a href="http://www.michaelpardo.com/2011/10/repeating-bitmaps-inside-layerlists/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve run into this particular issue several times now. It&#8217;s a bug in the Android SDK, which apparently has been fixed as of ICS (Ice Cream Sandwich). When you place a &lt;bitmap&gt; inside a &lt;layer-list&gt;, it tends to do whatever it feels like doing in regards to repeating the bitmap. Sometimes it will follow your instructions, and sometimes it won&#8217;t.</p>
<p>To fix this, just set the repeat mode in code. Here&#8217;s a snippet that will set all your Bitmaps repeating in a LayerDrawable.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> setLayerDrawableBitmapsRepeating<span style="color: #009900;">&#40;</span>LayerDrawable layerDrawable<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">int</span> size <span style="color: #339933;">=</span> layerDrawable.<span style="color: #006633;">getNumberOfLayers</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> size<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Drawable drawable <span style="color: #339933;">=</span> layerDrawable.<span style="color: #006633;">getDrawable</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>drawable <span style="color: #000000; font-weight: bold;">instanceof</span> BitmapDrawable<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>BitmapDrawable<span style="color: #009900;">&#41;</span> drawable<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setTileModeXY</span><span style="color: #009900;">&#40;</span>TileMode.<span style="color: #006633;">REPEAT</span>, TileMode.<span style="color: #006633;">REPEAT</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.michaelpardo.com/2011/10/repeating-bitmaps-inside-layerlists/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting visible bounds from a MapView</title>
		<link>http://www.michaelpardo.com/2011/10/getting-visible-bounds-from-a-mapview/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=getting-visible-bounds-from-a-mapview</link>
		<comments>http://www.michaelpardo.com/2011/10/getting-visible-bounds-from-a-mapview/#comments</comments>
		<pubDate>Wed, 12 Oct 2011 03:48:16 +0000</pubDate>
		<dc:creator>Michael Pardo</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://blog.michaelpardo.com/?p=6</guid>
		<description><![CDATA[MapView doesn&#8217;t have a getBounds() method, but using a couple of MapView&#8217;s other methods, it&#8217;s actually very easy to find the visible bounds. MapView has the methods getCenter(), getLongitudeSpan(), and getLatitudeSpan(). By combining these methods we can get the visible bounds. &#8230; <a href="http://www.michaelpardo.com/2011/10/getting-visible-bounds-from-a-mapview/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>MapView doesn&#8217;t have a getBounds() method, but using a couple of MapView&#8217;s other methods, it&#8217;s actually very easy to find the visible bounds. MapView has the methods getCenter(), getLongitudeSpan(), and getLatitudeSpan(). By combining these methods we can get the visible bounds.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">private</span> Rect getMapBounds<span style="color: #009900;">&#40;</span>MapView mapView<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">final</span> GeoPoint mapCenter <span style="color: #339933;">=</span> mapView.<span style="color: #006633;">getMapCenter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">int</span> lngHalfSpan <span style="color: #339933;">=</span> mapView.<span style="color: #006633;">getLongitudeSpan</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">int</span> latHalfSpan <span style="color: #339933;">=</span> mapView.<span style="color: #006633;">getLatitudeSpan</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> Rect<span style="color: #009900;">&#40;</span>mapCenter.<span style="color: #006633;">getLongitudeE6</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> lngHalfSpan, mapCenter.<span style="color: #006633;">getLatitudeE6</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> latHalfSpan,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mapCenter.<span style="color: #006633;">getLongitudeE6</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> lngHalfSpan, mapCenter.<span style="color: #006633;">getLatitudeE6</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> latHalfSpan<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.michaelpardo.com/2011/10/getting-visible-bounds-from-a-mapview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

