Football Fans: Download the 2012 Schedule App from Google Play!


Go Back   Android Forums > Android Development > Application Development

Application Development Dev Lounge for the Coder Folks



Reply
 
LinkBack Thread Tools
Old December 29th, 2011, 12:16 AM   #1 (permalink)
New Member
 
Join Date: Dec 2009
Posts: 5
 
Device(s): Motorola Droid
Thanks: 0
Thanked 1 Time in 1 Post
Default dialog layout breaks in ICS

Hi all,

I wrote a program a while back, and it works fine on gingerbread/froyo, but running on ICS, it breaks. the layout editor in eclipse displays it the way i expect, when using the android 4.0[.3]/theme.DeviceDefault.Dialog. However, when I load my program on to the galaxy nexus (or emulator), the dialog displays one column correctly, then squishes the other.

any help appreciated!!

quick description: i have two columns of form data (each column contains a text label & text input, each 125dp wide). so the whole layout should be ~500dp wide (each of the two columns is 250dp wide). see the attached screenshots for the expected layout on gingerbread vs the broken layout on ics.

manifest file (relative portion):
Code:
      <activity android:name="EditRecord"
         android:label="Edit Record"
         android:theme="@android:style/Theme.Dialog"
      >
.....
      </activity>

main layout file (landscape):
Code:
<LinearLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="horizontal"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:gravity="center_horizontal"
   android:id="@+id/root">
   <ScrollView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:paddingRight="5dp">
      <include
         layout="@layout/edit_record_top" />
   </ScrollView>
   <ScrollView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:paddingRight="5dp">
      <include
         layout="@layout/edit_record_bottom" />
   </ScrollView>
</LinearLayout>
Left column of layout (truncated to just show one row):
Code:
<merge
   xmlns:android="http://schemas.android.com/apk/res/android">
   <RelativeLayout
      android:layout_width="wrap_content"
      android:layout_height="wrap_content">
      <TextView
         android:layout_width="125dp"
         android:layout_height="wrap_content"
         android:text="@string/odo_label"
         android:layout_alignBaseline="@+id/odo_reading"
         android:id="@+id/odo_label" />
      <EditText
         android:layout_width="125dp"
         android:layout_height="wrap_content"
         android:maxLines="1"
         android:inputType="numberDecimal"
         android:layout_toRightOf="@id/odo_label"
         android:id="@+id/odo_reading" />
....
   </RelativeLayout>
</merge>
Right column of layout:
Code:
<merge
   xmlns:android="http://schemas.android.com/apk/res/android">
   <RelativeLayout
   android:layout_width="wrap_content"
   android:layout_height="wrap_content">
      <TextView
         android:layout_width="125dp"
         android:layout_height="wrap_content"
         android:id="@+id/date_label"
         android:layout_alignBaseline="@+id/date_reading"
         android:text="@string/date_label" />
      <!--
         this is the place where the date is entered. Once the text
         field is clicked on, a datePicker dialog box will show up,
         where the user can change the date. the default date will be
         the current date (encoded, if necessary)
      -->
      <EditText
         android:layout_width="125dp"
         android:layout_height="wrap_content"
         android:inputType="none|date"
         android:layout_toRightOf="@id/date_label"
         android:id="@+id/date_reading" />
....
      <Button
         android:id="@+id/submit"
         android:text="Submit Modifications"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_below="@id/mpg_diff_reading"
         android:layout_centerHorizontal="true" />
   </RelativeLayout>
</merge>
Attached Images
File Type: png broken_ics.png (51.0 KB, 7 views)
File Type: png working_gingerbread.png (55.0 KB, 7 views)

airswit is offline  
Reply With Quote
Sponsors
Old December 29th, 2011, 10:39 AM   #2 (permalink)
New Member
 
Join Date: Dec 2009
Posts: 5
 
Device(s): Motorola Droid
Thanks: 0
Thanked 1 Time in 1 Post
Default

okay, I stumbled on to a workaround (seems like a hack!). I need to apply the width=fill_parent attribute to the activity layout after it is inflated. I found the answer here:
Android dialog width - Stack Overflow
(which links to here: android - How to make an alert dialog fill 90% of srceen size? - Stack Overflow)

hopefully this helps someone else! Does anyone know why this is necessary, and if/when it will be addressed in Android?

Thanks
airswit is offline  
Reply With Quote
The Following User Says Thank You to airswit For This Useful Post:
alostpacket (December 30th, 2011)
Old December 30th, 2011, 07:13 PM   #3 (permalink)
Over Macho Grande?
 
alostpacket's Avatar
 
Join Date: Nov 2009
Location: NY
Posts: 7,090
 
Device(s): GalaxyNexus(LTE), NexusOne, OG Droid, GalaxyTab 10.1(LTE), Eris, Logitech Revue (fishtank)
Thanks: 4,164
Thanked 3,126 Times in 1,292 Posts
Default

Thanks for posting your work-around
alostpacket is offline  
Reply With Quote
Reply

Bookmarks


Go Back   Android Forums > Android Development > Application Development User CP
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -5. The time now is 12:00 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Custom vBulletin Skins by: Relivo