android ui with xml

20
ANDROID UI WITH XML J M GITHEKO MARCH 2016

Upload: egerton-university

Post on 23-Feb-2017

66 views

Category:

Technology


2 download

TRANSCRIPT

Android UI With xml

Android UI With xmlJ m GithekoMarch 2016

Android Studio User Interface ToolsLayout EditorDrag and drop user interface elements to build layouts for your app.

Theme Editor

Build re-usable user interface styles for layouts and widgets in your app.Translations EditorView and update all your string resource translations in one convenient place.Vector Asset StudioAdd material icons and import Scalable Vector Graphic (SVG) files into your Android Studio project as a drawable resource.Image Asset StudioGenerate custom icons for your Android applications from existing images, clipart, or text.

Ui Designer

Key UI ElementsLinear Layoutall the elements are displayed in linear fashion based on orientation i.e. either horizontally or vertically.Relative Layoutthe views are placed in related to one another.Listviewlist of scrollable itemsGridviewto display items in two dimensional scrolling grid (rows and columns)Scrollview & Horizontal Scrollviewhow items are make scrollableAbsolute Layoutabsolute layout displays views based on exact location of its children by using x and y coordinates. This view is depreciated in Android.Frame LayoutSpinnerdrop down-list allowing user to select one value from a set of values.TextViewdisplays text to the userEditTextused in applications when we need user to provide an input or text fieldButtonA button can be clicked, or pressed by the user to perform an actionOthersProgress bars

Other elements

Action barThe action bar is an important design element, usually at the top of each screen in an app, that provides a consistent familiar look between Android apps. It is used to provide better user interaction and experience by supporting easy navigation through tabs and drop-down lists. It also provides a space for the app or activitys identity, thus enabling the user to know their location in the app, and easy access to the actions that can be performed.

ContdBefore Android 3.0 Action Bar was not included in the SDK. You needed libraries to incorporate it into your design. Today, we have appcompat v7library or later. You may need to activate.

App icon This is used to identify your app with a logo or icon.View control This can also be used to identify the app or the specific activity the user is on by the title. If your app has different views, it can also be used to display these and allow for easy switching between views.Action buttons These are used to display the most important and/or often used actions. If there isnt enough space to show all of the action buttons, those that dont fit are automatically moved to the action overflow.Action overflow This is used for the lesser used actions.

Adding Actions to the Action BarTo add actions to the action bar, create a XML file in the res/menu directory where you will define each action. It is possible to define the actions in Java code, but you will write less code if you use XML.

ContdThe contents of res/menu/main_activity_bar.xml are shown in the next slide. In this example, were using the Action Bar Icon Pack for the action icons. Download it and copy the necessary icons to the res/drawable-xxxx directory for the different screen densities.

Strings.xmladd the string literals to res/values/strings.xml, as shown

ActionBar Settings Search Record Video Save Add Label Play Video Hello world! ActionBar Settings Search Record Video Save Add Label Play Video Hello world!

Java component of action barSee: http://www.sitepoint.com/better-user-interfaces-android-action-bar/To be covered in another lesson

fabSee Word document (too much code doesnt fit in PowerPoint

Color resource: Defines theme colours for your project

hex_color

Color example

#f00 #80ff0000

Dimensions:Used to define standard dimensions in your project

dimension

Dimension example

25dp 150dp 30dp 16sp

Other resource typeshttp://developer.android.com/guide/topics/resources/more-resources.html

Metrics, keylines and breakpointsMaterial design recommends standards dimensions for layouts.These are referred to as keylines

For responsive design, the layout should change depending on the device screen size and resolutionBreak points are the screen sizes where the app or web page is designed to automatically change layout. See following discussion: http://developer.android.com/guide/practices/screens_support.html