8 Replies - 835 Views - Last Post: 06 May 2012 - 01:21 PM

#1 sgt.assassin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 18-March 11

Android Layout Issue

Posted 03 May 2012 - 10:48 AM

If i have created the application in 2.2 android plaform and a user who decides to download the application and has a phone which is on 4.0.3 platform the layout of the application on the 4.0.3 phone tends to mess up. how do i go about correcting this?
Is This A Good Question/Topic? 0
  • +

Replies To: Android Layout Issue

#2 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 160
  • View blog
  • Posts: 1,009
  • Joined: 13-March 09

Re: Android Layout Issue

Posted 03 May 2012 - 12:09 PM

I don't really understand.
Dose the device with Android 4.0.3 have a different screen resolution?
Was This Post Helpful? 1
  • +
  • -

#3 H3R3T1C  Icon User is offline

  • Android Expert
  • member icon

Reputation: 275
  • View blog
  • Posts: 757
  • Joined: 30-March 07

Re: Android Layout Issue

Posted 03 May 2012 - 01:14 PM

can you post your layout?
Was This Post Helpful? 1
  • +
  • -

#4 htc(hot-taco-cheese)  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 16
  • View blog
  • Posts: 71
  • Joined: 04-December 10

Re: Android Layout Issue

Posted 03 May 2012 - 05:41 PM

you can always make separate layouts for each api version.

For example, you can create a layout.xml specifically for devices running version 4.0.3. Just make a folder in /res named like this: layout-v15. Anything not included in the version specific folder defaults to the regular layout folder, so you don't need to recreate every xml file.

This can also be done with your drawable or values folder
Was This Post Helpful? 1
  • +
  • -

#5 sgt.assassin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 18-March 11

Re: Android Layout Issue

Posted 04 May 2012 - 11:39 PM

What i mean is that when i download the application onto my HTC Phone (2.3.3) the buttons are correctly positioned in the middle however when the application is downloaded onto another device (4.0.3) the buttons tend to be out of place. for example one button will be at the bottom and the other will be at the top of the page. How do i go about correcting this issue?
Was This Post Helpful? 0
  • +
  • -

#6 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 160
  • View blog
  • Posts: 1,009
  • Joined: 13-March 09

Re: Android Layout Issue

Posted 05 May 2012 - 09:07 AM

Please post your xml-layout code :)
Was This Post Helpful? 1
  • +
  • -

#7 sgt.assassin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 18-March 11

Re: Android Layout Issue

Posted 05 May 2012 - 12:41 PM

The layout code is as below:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <LinearLayout style="@style/TitleBar">
        <ImageButton style="@style/TitleBarOperation"
            android:src="@drawable/home_def"
            android:onclick="onHome"
            android:layout_marginTop = "5dip"
            android:layout_marginRight="5dip"
            android:layout_marginLeft="5dip"
            android:layout_marginBottom = "5dip"
            android:paddingBottom = "5dip"
            android:background="@drawable/bg_state"
            android:layout_gravity="center"
            android:paddingLeft="5dip"
            android:paddingRight="7dip"/>

<ImageView android:layout_width="1px"
android:layout_height="fill_parent"
android:background="@drawable/separator"
android:layout_marginRight="7dip"
/>

        <TextView style="@style/TitleBarText"
         android:paddingLeft="8dip"/>
        
      </LinearLayout>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent">

   <ListView
      android:id="@+id/list_view_id"
      android:persistentDrawingCache="animation|scrolling"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:layoutAnimation="@anim/list_layout_controller" android:background="@drawable/imagess"/>
</LinearLayout>


</LinearLayout>

Was This Post Helpful? 0
  • +
  • -

#8 htc(hot-taco-cheese)  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 16
  • View blog
  • Posts: 71
  • Joined: 04-December 10

Re: Android Layout Issue

Posted 05 May 2012 - 01:33 PM

LinearLayouts are not the best for positioning. I personally prefer RelativeLayouts. You can align components better.

If you don't want to switch, there are better ways to center an item than positioning with padding and margins:
android:layout_centerVertical="true"
or
android:layout_centerHorizontal="true

dp units are not the same with every device resolution

This post has been edited by htc(hot-taco-cheese): 05 May 2012 - 01:35 PM

Was This Post Helpful? 1
  • +
  • -

#9 sgt.assassin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 18-March 11

Re: Android Layout Issue

Posted 06 May 2012 - 01:21 PM

Thank you for helping me out ive solved it now. Thnx
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1