Wrox Programmer Forums
|
BOOK: Beginning Android 4 Application Development
This is the forum to discuss the Wrox book Beginning Android 4 Application Development by Wei-Meng Lee; ISBN: 978-1-1181-9954-1
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Android 4 Application Development section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 29th, 2012, 02:04 AM
Registered User
 
Join Date: Nov 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs down Hello World App Not Displaying Correctly

Ok, so I just purchased the book and have run into the same issues with regard to the outdated version screenshots of the ADT for eclipse. I am running the latest version as of this date and have played around enough to get an emulator working for 4.0. The problem I am having with the Hello World example in chapter one is that the program runs, but the formatting is all off. The Hello world text is not centered as the code directs, the string is on top of the button and I cannot understand why this is. Can someone please explain. I am trying to work with the new relative layout default. Here is what I am looking at:

Code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="@string/hello_world" />
    
    <TextView 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/first_app" />
    
    <Button 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/click_button" />

</RelativeLayout>
AVD:

Device: 4.7" WXGA (1280X720: xhdpi)
Target: Android 4.0 - API Level 14
CPU/ABI: ARM (armeabi-v7a)
No Hardware Keyboard
Skin Hardware Controls
Front/Rear Cameras: None
Memory: RAM=512 VM Heap=64
Internal Storage: 200MB
SD Size: 10MB
Emulation Options: Snapshot


I can't insert an image to show the results but if you run the same AVD and code you should see what I am talking about. Any help would be appreciated.
 
Old January 1st, 2013, 06:54 PM
Registered User
 
Join Date: Apr 2012
Posts: 8
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi, maybe to late to answer this but anyhow.

If You use relative layout you should set an id to all of your view, like android:id="@+id/tvfirst" in the first textview.

Then in the second textview you set an other id like
android:id="@+id/tvsecond" below that you set the relation where to place the view with
android:layout_below="@+id/tvfirst"

And so on for every view object.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Ajax ComboBox not displaying item list correctly tomturner22 BOOK: ASP.NET AJAX Programmer's Reference : with ASP.NET 2.0 or ASP.NET 3.5 ISBN: 978-0-470-10998-4 0 July 26th, 2010 11:25 AM
Cannot display Hello World correctly in a browser Tofog BOOK: Professional ASP.NET 4 : in C# and VB 1 May 23rd, 2010 05:12 AM
Displaying Icons Within App Apocolypse2005 Visual Basic 2008 Professionals 0 June 11th, 2009 08:03 AM
Views not displaying correctly deanf7 BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8 3 March 16th, 2009 09:53 AM
02 IN 01 Desktop App (App+Wind Handler) pk_ocp .NET Framework 2.0 0 February 26th, 2008 02:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.