Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialkunalshitut
5,872 PointsDay layout problem
So I have designed the day list view layout as instructed in the lectures. I have aligned the temperatureLabel with the circle image view which is the background and also have set the gravity to center . But everytime I run the app in the emulator the temperatureLabel is displayed near the top of the circle rather than center. The previews properly show the temperature label being center-aligned but that is not the case while running.
6 Answers
Stijn van der Wielen
7,174 PointsAdding following line "android:layout_centerVertical="true"" fixed it for me
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/temperatureLabel"
android:layout_alignTop="@+id/circleImageView"
android:layout_alignBottom="@+id/circleImageView"
android:layout_alignLeft="@+id/circleImageView"
android:layout_alignRight="@+id/circleImageView"
android:layout_centerVertical="true"
android:gravity="center"
android:textColor="#f25019"
tools:text="100"/>
Seems to be a known issue https://code.google.com/p/android/issues/detail?id=59368
Matthew Barrus
16,731 PointsI have this problem on my Genymotion emulator of a Galaxy S5, but I installed the app to my LG G3 and everything displayed properly. Still, would be great to know if there is a style attribute with some compatibility issues.
kunalshitut
5,872 PointsI have tried running it on two real phones, a samsung galaxy s3 and an htc desire. I got the same problem in both cases. I also tried downloading the project files provided with the videos. Same problem there too.
Alex C
3,363 PointsSame problem on a LG G2. In Android Studio in the design tab it looks as expected but on phone the text is aligned top, centered only horizontally.
kunalshitut
5,872 PointsI tried running the app on a Samsung galaxy J5 with android 5.1 and 720p resolution and the problem is solved. I wonder if the problems might be due to the android version. My previous test phones were 4.3 and 4.4 android. Any insight into the problem will be greatly appreciated.
Alex C
3,363 Pointsso it seems that only android versions older than 5.0 has the problem. maybe someone from TeamTreeHouse can help? is there an attribute that works different in KitKat or previous versions?
Loren Pierce
9,318 PointsI found a fix on StackOverflow that worked. Inside the TextView in daily_list_item for temperatureLabel, add this property -- android:layout_centerInParent="true" . The temperature values are now properly centered.
kunalshitut
5,872 Pointskunalshitut
5,872 PointsThank you , that works perfectly