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 trial

Android

Cannot change TextView size graphically when using Eclipse for Android

Hey Ben and other users in this community ;)

I'm watching this video: http://teamtreehouse.com/library/android-development/build-an-android-crystal-ball-app/getting-started/initial-layout

I'm on a Mac as well, but when trying to click next to Text Size property in Eclipse (as you do at 3:45), I can't select that box and then enter my value there. May that be a problem of Eclipse, as I know it's open-source and has a lot of bugs?

I actually managed to change that by editing the activity xml file. The "32sp" value appear now in the properties area, but still can't edit it :(.

I've also noticed in your video that, although you entered "32sp", in the xml file you have "32dp". If I type "32dp" - I get a warning.

What actually 32dp means?

I am pretty familiar with iOS development technologies, and getting started with Android development gives me much overhead at the beginning :) . However, you guys are doing a GREAT job, and I hope to scrape my way through all the Android and feel confident when making apps on this platform ;).

Thank you very much However, I man

27 Answers

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

Good eyes, @Pavel! First, the problem changing the TextView size is a known issue. I added a note below the video, but it's easy to miss:

"Known Issue: On Mountain Lion, you are unable to edit certain properties in the Properties view, like Text Size for the TextView. The workaround is to right-click on the TextView and select Edit TextSize."

The 32dp was an error I had typed and I re-recorded the "sp" part, but I missed the "dp" in the XML view later on. I'll have to re-record that part some time. "dp" stands for density-independent pixels and is used to size most things in Android (and can be used for text), but "sp" stands for scale-independent pixels and is basically the same except it also takes into account the users personalized settings for text. For example, if the user made the default text on their phone larger than normal.

I wrote a small section about this that will be making its way onto the site soon. Hope this helps:

Units for Sizes

Don't use pixels for sizes in Android apps. Instead, use:

dp - Density-Independent pixels - Used for everything besides text. Takes into account the screen size and density to ensure uniformity across devices. android:layout_height="60dp" - Set a view to be 60 "pixels" wide. The actual number of pixels used will depend on the screen size and density.

sp - Scale-Independent pixels - Used for text. Takes into account the screen size and density as well as the user's preferences for text. android:textSize="32sp" - Set the text to be 32 "pixels" high. The actual number of pixels used will depend on the screen size and density as well as the user's preferences for text.

Thanks a lot, Ben. It really helped.

I have found a fix in here: https://android-review.googlesource.com/#/c/42238/

But how can we actually use that fix?

Thanks for you advice

@Ben Jakuben

Hi Ben, The issue I'm having is that when I right click and 'Edit Text', I get an error in the problems box saying:

'[I18N] Hardcoded string "2nd Page", should use @string resource'.

Can you help me out please :)

Thanks in Advance

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

That's just a warning that's safe to ignore. The best practice for using Strings in Android is to place all Strings in a resource file named strings.xml. We cover that in this video in the 2nd Android project.

I have another question.

How can I show 'Create New Android Application'? In the top toolbar in Eclipse. I only have create 'Create New Android XML'?

Thanks

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

Not sure what you mean - like a new button in the Toolbar for it? Here's a link on StackOverflow that talks about adding custom buttons to the toolbar:

http://stackoverflow.com/questions/10922919/add-re-add-buttons-to-toolbar-in-eclipse

Yep Thanks :) By the way, your an Awesome Tutor :) Thanks!

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

Awesome - thanks for the feedback! :smile:

If you are thinking of a Tutorial for Android. Expansion Files!! They are a relatively new thing to Google Play. But to be honest if you created a Tutorial on how to implement them, then you would be the first :) I have honestly looked everywhere :(

If you could help me, I would be forever grateful :)

Thanks again !!!

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

While that wouldn't fit into anything project-based for a while, that's a great idea for a blog post! I've added it to my list of blog post ideas, though I have a few others already assigned, so I can't promise anything in the near future. You're right, though, that there isn't much information available about them.

Thanks very much :)

Hey all,

So I'm having an issue with editing the text/button properties as well. I used the elipse to the right of the box to edit some things or right clicked over the text or button view to edit others, but I was unable to figure this out for color. Any ideas on how to change it? Also, now when i run it in the emulator, i get an error that says, "unfortunately crystal ball has stopped". The log console now show several runtime errors. I'm wondering if this is related to something I changed by editing the textView/buttonView the way I did. Has anyone else experienced this and know how to fix it?

thanks so much!

aaron

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

Color is a little...funny in Android. I talk a little bit about color in the Customizing Buttons and Labels video of Stage 3, so check that out as a starting point. That could very well be the cause of your runtime errors.

If you'd like me to help troubleshoot your code, you can always zip up your project directory and email us at help@teamtreehouse.com. Hope this helps!

thanks a lot, Ben. I'm new to Android/Eclipse, so i'm still trying to figure out how to zip the project to send it over. Stand by :)

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

Hey Aaron Watkins , I haven't gotten it yet (though it may not have been forwarded if you sent it). Your project will be in one folder with your project name inside your workspace folder. If you right-click on the project in the Project Explorer inside Eclipse, then select Project Properties at the bottom, then the location will be listed in the "Resource" section of Project Properties. Just zip up that folder and that's all we need!

Ben Jakuben my hero! :)

I am following along with your BlogReader course. I am currently at 'Requesting Data from the Web the Wrong Way'. I've noticed I'm getting a ClassCastException? Any reason why that would be? I have followed your tutorial exactly...

Thanks for your help!

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

Hey Josh Savage! Can you give us a little more detail about the ClassCastException? I can force one in my app by changing one of the casts from findViewById, and the exception in LogCat tells me the class it's actually seeing. So here's my LogCat, for example:

java.lang.ClassCastException: android.widget.ProgressBar

Hey Ben Jakuben!

I am sorry to bother you, I've found the problem, when I was creating the HttpURLConnection variable. I had accidentally written Https instead of Http..

Sorry!

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

Cool - I thought that might be the troublemaker! There are only a few places we are casting objects, so that makes sense! Glad it was an easy fix. :thumbsup:

Carrie Gildersleeve
Carrie Gildersleeve
9,609 Points

Hi Ben Jakuben! (and everybody else:)

I am loving your android dev class, you are so thorough! One thing tho, has anybody found a workaround for editing the textview text color in mountain lion? The only relevant item my googling has found is this discussion, when Aaron Watkins asked about it...

Carrie Gildersleeve
Carrie Gildersleeve
9,609 Points

Also, how do we tag people in these posts?! :)

Ben Jakuben
Ben Jakuben
Treehouse Teacher

Thanks, Carrie Gildersleeve! (<== Just type the @ symbol and then start typing a name - an autocomplete box should appear below this text box.)

The very latest version of Eclipse and the Android tools still don't have a fix for this. They do however at least have a hint about the bug that says it will be fixed with the next version of Eclipse (4.3), which should be available as the official build sometime soon.

For now, you can easily change the color in the XML view:

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#ffffff"
    android:textSize="32sp" />
Carrie Gildersleeve
Carrie Gildersleeve
9,609 Points

Your welcome! The problem I am having with the sidebar is that I can't type into it at all. I had been right clicking on the element and going into inherited from textview, but that just wasn't working for color. I should have thought about going into the actual code tho! Thanks for pointing that out!

Ken Barlow
Ken Barlow
16,177 Points

This really helped! Thanks!

I have a question: I am having all the above issues and the issues of not being able to change any of the properties, while I'm in the latest version of eclipse on Windows 7! I have to right click, go to other properties, go to defined by textview, then click a lot to scroll until I find the property I want to change, hopefully click on it, (or else restart) and then set the value. This is the only way I can then change that property later from the properties pane. How may I fix this?

Ben Jakuben
Ben Jakuben
Treehouse Teacher

I would recommend trying to get familiar with the XML view of the layouts. Once you get comfortable with that, it's MUCH easier to make changes in there. I actually almost never use the graphical editor except when first laying out things as a simple starting point.

XML. Would appreciate a series from you guys on that! It's like the basics of everything! Thanks!

Jeffrey Wambugu
Jeffrey Wambugu
8,548 Points

Hey Ben Jakuben I'm having the same problem i have looked around and the only solution I see is to change the API19 to a lower one but i only have that one on the drop down menu do you have any work around for this as it is really tedious to do the right click method and I could not edit the text-color using the right click method.

I agree with Jeffrey, I'm currently following the Crystal Ball tutorial and I also have this problem. Surely someone somewhere knows the solution to this problem. I can't seem to change the text color by using the right click method either so it's really beginning to give me a headache!

Jeffrey Wambugu
Jeffrey Wambugu
8,548 Points

Hey Daniel i found that if you go to the Android SDK Manager and install Android 4.3 (API 18). That seemed to do the trick but I still don't know why. Keep me posted if you need any problem.

Worked a charm! Thankyou so much!!