You are on page 1of 58
ANDROID USE INTERFACE) LLABUS TECH - HYDERABAD] its, Layouts-Linear, Relative, Grid Comp Buttons, Radio and Toggle Event Handling - Handling Clicks es of Various UI Components. ndroid ut the A a 11 understand and Sey In this chapter we wil i rs wil 3 ‘The Importance of creating a UI that your ue : ated. : area terminotogy by Androl Set aa a The following sections explores some nel © fe programming metaphors nil ie wn : (1) Views : They are as controls or widgets. from View (2) View Groups : views. It can exte interconnected child (3) Fragments used to enca particularly usef creating reusable “ Android equivalent of Forms i provides several comme ERBB Android User Interface Fundame All user interface elements in an And and Group objects. (1) View : A view is an object th interact with: creen that the user can ViewGroup + A ViewGroup is a i @ P o's an object thet holds other view and n in order to define the layout of the interface ViewGroup objects "APPLICATION DEVELOPMENT ‘each component ¢ fand ViewGroup, objects that are ViewGroup ——— EREB Assigning User A new ai Dur UE. To do that we have t: out resource to display. Bec most always use si andler. _ gle View instance. TI f external layout resou! By using layout resourc decouples our presentation layer from the applieatlogy logic, by providing the flexibility to change the presentation without changing the ead #0 this makes it possible to specify different layouts optimized for different hardware) Fonfigurations when changing them at runtime based on hardware changes, By using the findViewByld method we can obtain a reference to each oF a layout, myTexiView=(TextView) findViewByID(R. Id, myTextView); Be eaiconteniview methods accepts a single view Instance, 28 result, We Jayouts to add multiple controls to our activity. introducing Layouts f ss and are used 1} Layout or LayoutMangers are extensions position child Views within our UI. Layouts can t t > create arbitrarily gomplex UIs by using a combination of layo! jes a number Ofm layout classes. That we can use the to construgtl the UI for your Views, Fragmen Following list specifies some s that are available in the Android SDK (1) Frame Layout : These are the simp e framelayout pins each child view within it (2) Linear Layout : These Linear Lay horizontal line. er a vertical OF (8) RelativeLayout : It define the position: ve to the others ai to the screen boundaries. (4) GridLayout : It uses a rectangular grid « infinitely thin lines to layout Views in a st f rows and columns. This layout flexible and can be used to greatly simplify | EXEEE Defining Layouts The best way to define the layout is by using a XML external cura yous contain a single root element. : youl_width="match_parent™ android: layout_heigh ‘match_parent*> the position of and the other views. Pir Following program 3.1.3 modifies the layout that describes bither and that moves the buttons below the list view, most ‘APPLICATION DEVELOPME! ‘can create complex without ‘construct UIs by using the relative layout. MPONE we can use to r controls that we find design t frequently using ins ANDROID APPLICATION DEVELOPMENT PROFESSIONAL PUBLICATIONS —_— (1) Buttons : The represents a push-button widget (2) Eatext Views : A subclass of the TexView view, IE Its text content. except that It allow (@) CheckBox : It Is a spe tates they are (4) RadioGroup and Rac “http: //scheme android:orientation=*vertical* android:layout_width =", afidroid:layout_height="

You might also like