<?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>Stealthcopter.com &#187; xml</title>
	<atom:link href="http://www.stealthcopter.com/blog/tag/xml/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.stealthcopter.com/blog</link>
	<description>Android, Linux, Python and stealthcopters</description>
	<lastBuildDate>Fri, 13 Jan 2012 16:29:58 +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>Making Prettier Buttons in android; XML (rollover,selection &amp; focus effects), 9patch images and transparency</title>
		<link>http://www.stealthcopter.com/blog/2010/08/making-prettier-buttons-in-android-xml-rolloverselection-focus-effects-9patch-images-and-transparency/</link>
		<comments>http://www.stealthcopter.com/blog/2010/08/making-prettier-buttons-in-android-xml-rolloverselection-focus-effects-9patch-images-and-transparency/#comments</comments>
		<pubDate>Mon, 23 Aug 2010 14:04:42 +0000</pubDate>
		<dc:creator>mat</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=980</guid>
		<description><![CDATA[Alot of the soundboards out there on the market look a little bit ugly by using the default android buttons in conjunction with a background (no offense to developers of these, perhaps they can learn from this); this mini-tutorial explains how to use xml to create a customised nice looking button thing. Ugly Buttons: Below [...]]]></description>
			<content:encoded><![CDATA[<p>Alot of the soundboards out there on the market look a little bit ugly by using the default android buttons in conjunction with a background (no offense to developers of these, perhaps they can learn from this); this mini-tutorial explains how to use xml to create a customised nice looking button thing.</p>
<p><strong>Ugly Buttons:</strong><br />
Below is show the example I will use to demonstrate the default buttons in use with a background image (It&#8217;s a picture of me hugging the <a href="http://www.stealthcopter.com/blog/2010/05/photos-of-the-android-statues-outside-building-44/">android statue</a>!)</p>
<p><a href="http://www.stealthcopter.com/blog/2010/08/making-prettier-buttons-in-android-xml-rolloverselection-focus-effects-9patch-images-and-transparency/ugly_buttons/" rel="attachment wp-att-981"><img src="http://www.stealthcopter.com/blog/wp-content/uploads/2010/08/ugly_buttons.png" alt="&quot;Ugly&quot; default buttons in android" title="&quot;Ugly&quot; default buttons in android" width="319" height="428" class="size-full wp-image-981" /></a></p>
<p><strong>Button States</strong></p>
<p>There are four images you will need to create (you can use less if you want); one for each of the following states:</p>
<table>
<tr>
<th>state_focused</th>
<th>state_pressed</th>
<th>What this means</th>
</tr>
<tr>
<td>true</td>
<td>false</td>
<td>Button highlighted (selected with trackpad)</td>
</tr>
<tr>
<td>true</td>
<td>true</td>
<td>Button foussed and pressed</td>
</tr>
<tr>
<td>false</td>
<td>true</td>
<td>Button pressed</td>
</tr>
<tr>
<td>false</td>
<td>false</td>
<td>Normal state of button</td>
</tr>
</table>
<p>I recommend creating a <a href="http://developer.android.com/guide/developing/tools/draw9patch.html">nine-patch png</a> for the button image, this way your image can be stretched to fit the button size as needed. Also soundboards look rather snazzy if you include a background image, and then you can use transparency in your png so that your buttons don&#8217;t obscure it.</p>
<p><div id="attachment_982" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.stealthcopter.com/blog/2010/08/making-prettier-buttons-in-android-xml-rolloverselection-focus-effects-9patch-images-and-transparency/9patch/" rel="attachment wp-att-982"><img src="http://www.stealthcopter.com/blog/wp-content/uploads/2010/08/9patch-600x347.png" alt="draw9patch tool button android " title="android 9patch png" width="600" height="347" class="size-medium wp-image-982" /></a><p class="wp-caption-text">Using draw9patch tool to make a 9patch png for use as a strechable button</p></div></p>
<p><strong>XML Code</strong></p>
<p><em>button.xml</em></p>
<pre>
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt;
    &lt;item android:state_focused="true"
	android:state_pressed="false"
	android:drawable="@drawable/button_selected" /&gt;
    &lt;item android:state_focused="true"
    	  android:state_pressed="true"
    	  android:drawable="@drawable/button_focus" /&gt;
    &lt;item android:state_focused="false"
    	  android:state_pressed="true"
	  android:drawable="@drawable/button_pressed" /&gt;
    &lt;item android:drawable="@drawable/button_normal" /&gt;
&lt;/selector&gt;
</pre>
<p><em>main.xml</em><br />
An example usage of how to use this newly created xml button in your layout file.</p>
<pre>
&lt;Button
android:id="@+id/mysexynewbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30sp"
android:textStyle="bold"
android:text="Stealthcopter FTW"
android:background="@drawable/button" /&gt;
</pre>
<p><strong>Results</strong><br />
Now you should have some nice sexy customised buttons that change depending on thier state. Which makes our example now look like this (I increased the padding and margins of the buttons slightly):</p>
<p><div id="attachment_983" class="wp-caption aligncenter" style="width: 327px"><a href="http://www.stealthcopter.com/blog/2010/08/making-prettier-buttons-in-android-xml-rolloverselection-focus-effects-9patch-images-and-transparency/pretty_buttons/" rel="attachment wp-att-983"><img src="http://www.stealthcopter.com/blog/wp-content/uploads/2010/08/pretty_buttons.png" alt="Pretty Buttons with transparency using 9patch png and xml" title="Pretty Buttons with transparency using 9patch png and xml" width="317" height="430" class="size-full wp-image-983" /></a><p class="wp-caption-text">Pretty Buttons with transparency using 9patch png and xml</p></div></p>
<p>Below are a few examples of my work with some nice transparent buttons:</p>
<style type='text/css'> 
			#gallery-1 {
				margin: auto;
			}
			#gallery-1 .gallery-item {
				float: left;
				margin-top: 10px;
				text-align: center;
				width: 33%;			}
			#gallery-1 img {
				border: 2px solid #cfcfcf;
			}
			#gallery-1 .gallery-caption {
				margin-left: 0;
			}
		</style>
<p>		<!-- see gallery_shortcode() in wp-includes/media.php --> </p>
<div id='gallery-1' class='gallery galleryid-972'>
<dl class='gallery-item'>
<dt class='gallery-icon'>
				<a href='http://www.stealthcopter.com/blog/2010/08/android-soundpool-vs-mediaplayer-focus-on-soundboards-and-memory-problems/counterstrikesb_ss1/' title='Counter Strike Soundboard'><img width="150" height="150" src="http://www.stealthcopter.com/blog/wp-content/uploads/2010/08/counterstrikesb_ss1-150x150.png" class="attachment-thumbnail" alt="Counter Strike Soundboard" title="Counter Strike Soundboard" /></a>
			</dt>
<dd class='gallery-caption'>
				Counter Strike Soundboard
				</dd>
</dl>
<dl class='gallery-item'>
<dt class='gallery-icon'>
				<a href='http://www.stealthcopter.com/blog/2010/08/android-soundpool-vs-mediaplayer-focus-on-soundboards-and-memory-problems/garthss1/' title='Garth Marenghi Soundboard'><img width="150" height="150" src="http://www.stealthcopter.com/blog/wp-content/uploads/2010/08/garthss1-150x150.png" class="attachment-thumbnail" alt="Garth Marenghi Soundboard" title="Garth Marenghi Soundboard" /></a>
			</dt>
<dd class='gallery-caption'>
				Garth Marenghi Soundboard
				</dd>
</dl>
<dl class='gallery-item'>
<dt class='gallery-icon'>
				<a href='http://www.stealthcopter.com/blog/2010/08/android-soundpool-vs-mediaplayer-focus-on-soundboards-and-memory-problems/itcrowd_ss1/' title='IT Crowd Soundboard'><img width="150" height="150" src="http://www.stealthcopter.com/blog/wp-content/uploads/2010/08/itcrowd_ss1-150x150.png" class="attachment-thumbnail" alt="IT Crowd Soundboard" title="IT Crowd Soundboard" /></a>
			</dt>
<dd class='gallery-caption'>
				IT Crowd Soundboard
				</dd>
</dl>
<p><br style="clear: both" /></p>
<dl class='gallery-item'>
<dt class='gallery-icon'>
				<a href='http://www.stealthcopter.com/blog/2010/08/android-soundpool-vs-mediaplayer-focus-on-soundboards-and-memory-problems/jafool_ss1/' title='Jafool fonejacker soundboard'><img width="150" height="150" src="http://www.stealthcopter.com/blog/wp-content/uploads/2010/08/jafool_ss1-150x150.png" class="attachment-thumbnail" alt="Jafool fonejacker soundboard" title="Jafool fonejacker soundboard" /></a>
			</dt>
<dd class='gallery-caption'>
				Jafool fonejacker soundboard
				</dd>
</dl>
<dl class='gallery-item'>
<dt class='gallery-icon'>
				<a href='http://www.stealthcopter.com/blog/2010/08/android-soundpool-vs-mediaplayer-focus-on-soundboards-and-memory-problems/portalss1/' title='Portal Soundboard'><img width="150" height="150" src="http://www.stealthcopter.com/blog/wp-content/uploads/2010/08/portalss1-150x150.png" class="attachment-thumbnail" alt="Portal Soundboard" title="Portal Soundboard" /></a>
			</dt>
<dd class='gallery-caption'>
				Portal Soundboard
				</dd>
</dl>
<dl class='gallery-item'>
<dt class='gallery-icon'>
				<a href='http://www.stealthcopter.com/blog/2010/08/android-soundpool-vs-mediaplayer-focus-on-soundboards-and-memory-problems/utsoundboard_ss1-2/' title='Unreal Tournament Soundboard'><img width="150" height="150" src="http://www.stealthcopter.com/blog/wp-content/uploads/2010/08/UTsoundboard_ss1-150x150.png" class="attachment-thumbnail" alt="Unreal Tournament Soundboard" title="Unreal Tournament Soundboard" /></a>
			</dt>
<dd class='gallery-caption'>
				Unreal Tournament Soundboard
				</dd>
</dl>
<p><br style="clear: both" /></p>
<dl class='gallery-item'>
<dt class='gallery-icon'>
				<a href='http://www.stealthcopter.com/blog/2010/08/android-soundpool-vs-mediaplayer-focus-on-soundboards-and-memory-problems/qrcode/' title='Check out my apps'><img width="150" height="150" src="http://www.stealthcopter.com/blog/wp-content/uploads/2010/08/qrcode-150x150.png" class="attachment-thumbnail" alt="Check out my apps" title="Check out my apps" /></a>
			</dt>
<dd class='gallery-caption'>
				Check out my apps
				</dd>
</dl>
<p>			<br style='clear: both;' />
		</div>
<p><strong>Example 9 patch image</strong><br />
<div id="attachment_1112" class="wp-caption aligncenter" style="width: 29px"><a href="http://www.stealthcopter.com/blog/2010/08/making-prettier-buttons-in-android-xml-rolloverselection-focus-effects-9patch-images-and-transparency/button-9/" rel="attachment wp-att-1112"><img src="http://www.stealthcopter.com/blog/wp-content/uploads/2010/08/button.9.png" alt="button.9.png" title="button.9.png" width="19" height="16" class="size-full wp-image-1112" /></a><p class="wp-caption-text">button.9.png</p></div></p>
]]></content:encoded>
			<wfw:commentRss>http://www.stealthcopter.com/blog/2010/08/making-prettier-buttons-in-android-xml-rolloverselection-focus-effects-9patch-images-and-transparency/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Saving settings in python with YAML (an XML alternative)</title>
		<link>http://www.stealthcopter.com/blog/2010/02/saving-settings-in-python-with-yaml-an-xml-alternative/</link>
		<comments>http://www.stealthcopter.com/blog/2010/02/saving-settings-in-python-with-yaml-an-xml-alternative/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 12:03:08 +0000</pubDate>
		<dc:creator>mat</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[yaml]]></category>

		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=770</guid>
		<description><![CDATA[When transferring information or settings between computers and programs is is useful to use something simple and program independent. For a recent project I need to send a settings file between a PHP script and a python program, I needed something that would support trees so an INI file was out of the question, and [...]]]></description>
			<content:encoded><![CDATA[<p>When transferring information or settings between computers and programs is is useful to use something simple and program independent. For a recent project I need to send a settings file between a PHP script and a python program, I needed something that would support trees so an INI file was out of the question, and I naturally thought of using XML, however when looking for more information I stumbled upon YAML (seemingly forgotten alternative to XML).</p>
<p><a href="http://www.yaml.org/spec/1.2/spec.html">YAML</a> is a recursive acronym that stands for YAML Ain&#8217;t Markup Language and below is a simplified example taken from the YAML site. The layout is similar to python with indents representing the nested layers. Semicolons are used to seperate variable names and value pairs.</p>
<pre name="code" class="python">
name   : Joe Bloggs
product:
    - sku         : BL394D
      quantity    : 4
      description : Basketball
      price       : 450.00
    - sku         : BL4438H
      quantity    : 1
      description : Super Hoop
      price       : 2392.00
tax  : 251.42
total: 4443.5
</pre>
<p>To use YAML in python you will need the PyYAML library avaliable <a href="http://pyyaml.org/wiki/PyYAML">here</a> or in via your package manager in linux. (I.E. &#8220;sudo apt-get install http://pyyaml.org/wiki/PyYAML&#8221; in ubuntu/debian).</p>
<p>The code for then using YAML is very simple, first we import the yaml library, then we open our settings file we have created and then use yaml&#8217;s load feature to load our settings into a python dictionary, and then finally printing it out so we can see what it contains</p>
<pre name="code" class="python">
import yaml
f=open('settings.cfg')
settings=yaml.load(f)
print settings
</pre>
<p>Using the example YAML file above saved to settings.cfg this python script will output the following when run:</p>
<pre name="code" class="python">
{'product': [{'sku': 'BL394D', 'price': 450.0, 'description':
'Basketball', 'quantity': 4}, {'sku': 'BL4438H', 'price': 2392.0,
'description': 'Super Hoop', 'quantity': 1}], 'total': 4443.5, 'tax':
251.41999999999999, 'name': 'Joe Bloggs'}
</pre>
<p>We can now access all the information in the file very easily (I.E. settings['name'] will give us the name Joe Bloggs).</p>
<p>YAML supports much much more than what is discussed here and further information can be found on the YAML website.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stealthcopter.com/blog/2010/02/saving-settings-in-python-with-yaml-an-xml-alternative/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

