<?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>Droidweb.com &#187; layout design</title>
<atom:link href="http://droidweb.com/tag/layout-design/feed/" rel="self" type="application/rss+xml" />
<link>http://droidweb.com</link>
<description>Your source for Android application reviews, programming tips, and other Android advice</description>
<lastBuildDate>Fri, 23 Dec 2011 13:21:14 +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>Starting Android Development Part 3: Layout Tutorial 2</title>
<link>http://droidweb.com/2010/01/starting-android-development-part-3-layout-tutorial-2/</link>
<comments>http://droidweb.com/2010/01/starting-android-development-part-3-layout-tutorial-2/#comments</comments>
<pubDate>Wed, 06 Jan 2010 05:43:18 +0000</pubDate>
<dc:creator>Maliek Mcknight</dc:creator>
<category>
<![CDATA[Android Development Corner]]>
</category>
<category>
<![CDATA[Programming]]>
</category>
<category>
<![CDATA[Android Developer Center]]>
</category>
<category>
<![CDATA[development]]>
</category>
<category>
<![CDATA[layout design]]>
</category>
<guid isPermaLink="false">http://www.blog.droidweb.com/?p=1312</guid>
<description>
<![CDATA[As promised, here’s part two of my coverage on layouts in Android.&#160; Lets pick up where we left off, namely we just created a main.xml file for layout of our...]]>
</description>
<content:encoded>
<![CDATA[</p>
<p> <img title="ADC_logo" style="display: block; float: none; margin-left: auto; margin-right: auto" height="253" alt="" src="http://www.blog.droidweb.com/wp-content/uploads/2009/12/ADC_logo1-300x253.png" width="300" />
<p>As promised, here’s part two of my coverage on layouts in Android.&#160; Lets pick up where we left off, namely we just created a main.xml file for layout of our temperature conversion application.</p>
<p>So you know what we’re trying to achieve here, here’s a screenshot of the final product.</p>
<p><a href="http://droidweb.com/wp-content/uploads/2010/01/temp_screen_final.png"><img title="temp_screen_final" style="border-right: 0px; border-top: 0px; display: block; float: none; margin-left: auto; border-left: 0px; margin-right: auto; border-bottom: 0px" height="244" alt="temp_screen_final" src="http://droidweb.com/wp-content/uploads/2010/01/temp_screen_final_thumb.png" width="194" border="0" /></a> </p>
<p>I know what you’re thinking.&#160; That’s not that cute of a layout.&#160; I’ll leave the job of making really pretty layouts to you after you learn the basics.&#160; For now this layout will do to show you how making layouts in Android works.</p>
<p>This layout consists of a TableLayout (A Linear Layout could have done here as well).&#160; Each table row has other items embedded in it.&#160; One row even has a TableLayout embedded within it (just to show that you can do this).&#160; This is a valid layout, but is generally frowned upon, as embedding table layouts within table layouts can lead to slower UI performance in the long run.</p>
<p>Here’s the code for the layout:</p>
<blockquote><p>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;     <br />&lt;TableLayout      <br />android:id=&quot;@+id/widget45&quot;      <br />android:layout_width=&quot;fill_parent&quot;      <br />android:layout_height=&quot;fill_parent&quot;      <br />android:orientation=&quot;vertical&quot;      <br />xmlns:android=&quot;<a href="http://schemas.android.com/apk/res/android&quot;">http://schemas.android.com/apk/res/android&quot;</a>      <br />&gt;      <br />&lt;TextView      <br />android:id=&quot;@+id/title&quot;      <br />android:layout_width=&quot;fill_parent&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:background=&quot;#ff0000ff&quot;      <br />android:padding=&quot;10px&quot;      <br />android:text=&quot;Temperature Conversion App&quot;      <br />android:textSize=&quot;18px&quot;      <br />android:typeface=&quot;sans&quot;      <br />android:textStyle=&quot;bold&quot;      <br />&gt;      <br />&lt;/TextView&gt;      <br />&lt;TableLayout      <br />android:id=&quot;@+id/widget62&quot;      <br />android:layout_width=&quot;319px&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:orientation=&quot;vertical&quot;      <br />&gt;      <br />&lt;TableRow      <br />android:id=&quot;@+id/widget63&quot;      <br />android:layout_width=&quot;149px&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:orientation=&quot;horizontal&quot;      <br />&gt;      <br />&lt;EditText      <br />android:id=&quot;@+id/User_input_F&quot;      <br />android:layout_width=&quot;fill_parent&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:textSize=&quot;18sp&quot;      <br />android:text=&quot; &quot;      <br />&gt;      <br />&lt;/EditText&gt;      <br />&lt;TextView      <br />android:id=&quot;@+id/widget78&quot;      <br />android:layout_width=&quot;wrap_content&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:text=&quot;(ºF)&quot;      <br />&gt;      <br />&lt;/TextView&gt;      <br />&lt;/TableRow&gt;      <br />&lt;TableRow      <br />android:id=&quot;@+id/widget64&quot;      <br />android:layout_width=&quot;fill_parent&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:orientation=&quot;horizontal&quot;      <br />&gt;      <br />&lt;EditText      <br />android:id=&quot;@+id/User_input_C&quot;      <br />android:layout_width=&quot;fill_parent&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:textSize=&quot;18sp&quot;      <br />android:text=&quot; &quot;      <br />&gt;      <br />&lt;/EditText&gt;      <br />&lt;TextView      <br />android:id=&quot;@+id/widget79&quot;      <br />android:layout_width=&quot;wrap_content&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:text=&quot;(ºC)&quot;      <br />&gt;      <br />&lt;/TextView&gt;      <br />&lt;/TableRow&gt;      <br />&lt;TableRow      <br />android:id=&quot;@+id/widget65&quot;      <br />android:layout_width=&quot;fill_parent&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:orientation=&quot;horizontal&quot;      <br />&gt;      <br />&lt;EditText      <br />android:id=&quot;@+id/widget83&quot;      <br />android:layout_width=&quot;fill_parent&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:textSize=&quot;18sp&quot;      <br />android:text=&quot; &quot;      <br />&gt;      <br />&lt;/EditText&gt;      <br />&lt;TextView      <br />android:id=&quot;@+id/User_input_K&quot;      <br />android:layout_width=&quot;wrap_content&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:text=&quot;(ºK)&quot;      <br />&gt;      <br />&lt;/TextView&gt;      <br />&lt;/TableRow&gt;      <br />&lt;/TableLayout&gt;      <br />&lt;TableRow      <br />android:id=&quot;@+id/Conversion&quot;      <br />android:layout_width=&quot;fill_parent&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:orientation=&quot;horizontal&quot;      <br />&gt;      <br />&lt;TextView      <br />android:id=&quot;@+id/conversion&quot;      <br />android:layout_width=&quot;fill_parent&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:text=&quot;Convert to:&quot;      <br />&gt;      <br />&lt;/TextView&gt;      <br />&lt;RadioGroup      <br />android:id=&quot;@+id/widget144&quot;      <br />android:layout_width=&quot;wrap_content&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:orientation=&quot;vertical&quot;      <br />&gt;      <br />&lt;RadioButton      <br />android:id=&quot;@+id/F_Select&quot;      <br />android:layout_width=&quot;fill_parent&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:text=&quot;Fareinheit&quot;      <br />&gt;      <br />&lt;/RadioButton&gt;      <br />&lt;RadioButton      <br />android:id=&quot;@+id/C_Select&quot;      <br />android:layout_width=&quot;wrap_content&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:text=&quot;Celcius&quot;      <br />&gt;      <br />&lt;/RadioButton&gt;      <br />&lt;RadioButton      <br />android:id=&quot;@+id/K_Select&quot;      <br />android:layout_width=&quot;wrap_content&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:text=&quot;Kelvin&quot;      <br />&gt;      <br />&lt;/RadioButton&gt;      <br />&lt;/RadioGroup&gt;      <br />&lt;/TableRow&gt;      <br />&lt;TableRow      <br />android:id=&quot;@+id/widget84&quot;      <br />android:layout_width=&quot;fill_parent&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:orientation=&quot;horizontal&quot;      <br />&gt;      <br />&lt;Button      <br />android:id=&quot;@+id/Calculate&quot;      <br />android:layout_width=&quot;wrap_content&quot;      <br />android:layout_height=&quot;wrap_content&quot;      <br />android:text=&quot;Calculate&quot;      <br />&gt;      <br />&lt;/Button&gt;      <br />&lt;/TableRow&gt;      <br />&lt;/TableLayout&gt; </p>
</blockquote>
<p>Note how each element has an id attribute (android:id) and the value of that attribute starts with <a href="mailto:&ldquo;@+id/name">“@+id/<em>name</em>”</a>.&#160; <a href="mailto:&ldquo;@+id/">“@+id/</a>” identifies the name by which you can refer to this<br />
layout element later in your java programming.&#160; Other things to note include:</p>
<ul>
<li><strong>android:layout_width</strong> and <strong>android:layout_height</strong>: Use these to determine how much space an element is going to take up.&#160; These can have two values: wrap_content and fill_parent.&#160; Wrap content means the element will only be as large as it needs to be to display its content.&#160; Fill_parent means the element will fill all available space it can, as determined by the parent element it resides in</li>
<li>To find the attribute applicable to a given layout, check out that layouts documentation at the developer.android.com/reference website.&#160; E.g. the API site for TableLayout is     <br /><a title="http://developer.android.com/reference/android/widget/TableLayout.html" href="http://developer.android.com/reference/android/widget/TableLayout.html">http://developer.android.com/reference/android/widget/TableLayout.html</a>. I usually find the page i need by just searching “android layout” and the name of the element I’m using</li>
</ul>
<p>In the next post of this series I will discuss some common Android layout elements, what they look like, and some of the attributes associated with that element.&#160; Then it’ll be time to connect our layout (frontend) to the logic that makes it work (the backend).&#160; For now check out the code I provided, try to understand how it works, and practice creating your own Android layouts!</p>
]]>
</content:encoded>
<wfw:commentRss>http://droidweb.com/2010/01/starting-android-development-part-3-layout-tutorial-2/feed/</wfw:commentRss>
<slash:comments>2</slash:comments>
</item>
<item>
<title>Starting Android Development Part 3: Layout Tutorial 1</title>
<link>http://droidweb.com/2010/01/starting-android-development-part-3-layout-tutorial-1/</link>
<comments>http://droidweb.com/2010/01/starting-android-development-part-3-layout-tutorial-1/#comments</comments>
<pubDate>Tue, 05 Jan 2010 21:28:48 +0000</pubDate>
<dc:creator>Maliek Mcknight</dc:creator>
<category>
<![CDATA[Android Development Corner]]>
</category>
<category>
<![CDATA[Programming]]>
</category>
<category>
<![CDATA[android]]>
</category>
<category>
<![CDATA[Android Developer Center]]>
</category>
<category>
<![CDATA[development]]>
</category>
<category>
<![CDATA[layout design]]>
</category>
<guid isPermaLink="false">http://www.blog.droidweb.com/?p=1306</guid>
<description>
<![CDATA[Now that I’ve bored you to death with details about how Android programming works, lets actually put something together, shall we?  This post will deal mainly with creating layouts in...]]>
</description>
<content:encoded>
<![CDATA[<p><img style="display: block; float: none; margin-left: auto; margin-right: auto;" title="ADC_logo" src="http://www.blog.droidweb.com/wp-content/uploads/2009/12/ADC_logo1-300x253.png" alt="" width="300" height="253" /></p>
<p>Now that I’ve bored you to death with details about how Android programming works, lets actually put something together, shall we?  This post will deal mainly with creating layouts in Android and will finish up with a sample layout for our Temperature Conversion project.</p>
<p>For what Google has to say about layouts check out their developers site at <a href="http://developer.android.com/guide/topics/ui/index.html">http://developer.android.com/guide/topics/ui/index.html</a>.</p>
<p>Now let me explain a little of what you read.  Layouts for Android screens are described in XML files in your /res/layout/ folder.  The XML file describes a hierarchy of layout elements.  The higher level elements determine the where of your layout and the lower level elements within these elements determine the what of your layout.</p>
<p>Ok that was a mouthful.  Lets look at the <em>simple</em> example Google provided:</p>
<blockquote><p>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;utf-8&#8243;?&gt;<br />
&lt;LinearLayout xmlns:android=&#8221;<a href="http://schemas.android.com/apk/res/android&quot;">http://schemas.android.com/apk/res/android&#8221;</a><br />
android:layout_width=&#8221;fill_parent&#8221;<br />
android:layout_height=&#8221;fill_parent&#8221;<br />
android:orientation=&#8221;vertical&#8221; &gt;<br />
&lt;TextView android:id=&#8221;@+id/text&#8221;<br />
android:layout_width=&#8221;wrap_content&#8221;<br />
android:layout_height=&#8221;wrap_content&#8221;<br />
android:text=&#8221;Hello, I am a TextView&#8221; /&gt;<br />
&lt;Button android:id=&#8221;@+id/button&#8221;<br />
android:layout_width=&#8221;wrap_content&#8221;<br />
android:layout_height=&#8221;wrap_content&#8221;<br />
android:text=&#8221;Hello, I am a Button&#8221; /&gt;<br />
&lt;/LinearLayout&gt;</p></blockquote>
<p>The Linear Layout describes the where, e.g. how the elements within this tag are going to be positioned in relation to each other.  TextView and Button are two lower level elements which are UI elements the user will interact with (a box in which to enter data and a clickable button, respectively)</p>
<p>The result of that layout is listed below.  Note the fact that Linear Layout makes the elements line up one below another (We’ll get into the alternative options later).</p>
<p style="text-align: center;"><a href="http://www.blog.droidweb.com/wp-content/uploads/2010/01/Picture 3.png"><img class="aligncenter" style="border: 0pt none; display: block;" src="http://droidweb.com/wp-content/uploads/2010/01/Picture3_thumb.png" border="0" alt="Click Me to Make Me Bigger!" width="244" height="198" /></a></p>
<p>Armed with this knowledge, lets try to make our own Layout.</p>
<ul>
<li>Go to File &gt; New &gt; Other</li>
<li>Click on Android &gt; Android XML file</li>
<li>Click Next</li>
<li>In the resulting screen fill out the following values:</li>
<li>Project: Click Browse and select the project you want to associate this XML file with (for this demonstration it would be whatever you named the temperature conversation application project)</li>
<li>File: Call this file main.xml</li>
<li>Click Layout for the type of resource</li>
<li>Choose Linear Layout for the root element of the XML file</li>
</ul>
<p>Everything should look similar to the screenshot below:</p>
<p><a href="http://droidweb.com/wp-content/uploads/2010/01/Picture5.png"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="Picture 5" src="http://droidweb.com/wp-content/uploads/2010/01/Picture5_thumb.png" border="0" alt="Picture 5" width="244" height="243" /></a></p>
<ul>
<li>Click Finish</li>
</ul>
<p>In the coming posts in this series I will go over an actual layout and discuss some of the common layout elements for Android programs.  Stay Tuned!</p>
]]>
</content:encoded>
<wfw:commentRss>http://droidweb.com/2010/01/starting-android-development-part-3-layout-tutorial-1/feed/</wfw:commentRss>
<slash:comments>0</slash:comments>
</item>
</channel>
</rss>
<!-- Served from: blog.droidweb.com @ 2012-02-09 03:12:27 by W3 Total Cache -->
