Eclipse - Android TextView widget - No properties dialog - android

I am new to Eclipse and Android development so it is quite possible I am missing something that is obvious to others. I have a basic Android project and in the graphical layout editor for Activity_Main.xml I find that I am not able to access the property dialogs for most of the TextView properties. I have included a screen capture. I expected a dialog box listing possible color choices for the text or at least an area where I could type in a hex code. I am using Eclipse - Kepler Service Release 1. Thank you.

You have to choose a colour from a resource.
To do that, open up your Strings.xml file, and add a colour to it. Example:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">example</string>
<color name="PURPLE">#800080</color>
</resources>
Then in your activity_main.xml, add this property to your TextView (reference the resource):
android:textColor="#color/PURPLE"
and/or (for other widgets, such as buttons)
android:background="#color/PURPLE"
However, if you wanted the way you were doing it, you still can. After you created your color called PURPLE, you can click on the ellipsis (...) for Text Color, and then click the Color heading, and then select the color (PURPLE will be there, along with all of the other colors you create).
Sources:
How to change background color in android app
Web colors in an Android color xml resource file
TextView | Android Developers
Color | Android Developers
android:textSize

Related

Android Studio "paint brush" icon in front of certain attributes

In the attributes pane, I occasionally see two attributes with the same name, where one attribute has what looks like a "paint brush" icon in front of it (for example, in the screenshot below, the text attribute). I've searched but can't find what this means or what the difference is between the attributes.
If you enter some text in the text field with the "paint brush" icon
then this attribute will be added to the xml:
tools:text="989"
this attribute, from the tools namespace (xmlns:tools="http://schemas.android.com/tools"),
is set for design time, a value you can see in the preview of the layout and it is not compiled.
If you enter some text in the text field without the "paint brush" icon then this attribute will be added to the xml:
android:text="888"
this is the attribute that will be compiled in the apk of your app and you will see when you run the app.

Custom button style with font style

Going to create android app, but as client requirement.
I have to come up with custom style buttons and radio button.
Review the attached image
How can I make the button and input field same as 'bullet point 1'.
How to use custom Arabic font style.
(i.e https://fonts.google.com/specimen/Cairo)
For bullet point 1, I would suggest you to use 9-patch images with stretchable area on top & bottom lines & keeping the circular arc on left/right edges of same radius.
I can try to create same 9-patch image for you, but it's gonna take time :) (give me the color codes you want to use in)
For using Arabic fonts, please go through this Android Developer link Android Custom Fonts.
There are plenty of answers out there on how to use custom fonts, so you can easily find any one.
Here's how you can easily use that Cairo fonts types:
Download the Cairo font zip file, unzip it & put all .ttf or .otf files inside your Project -> app -> src -> main -> res -> font folder
Add below lines into your styles.xml file under res->values folder:
<style name="cairo_semi_bold">
<item name="android:fontFamily">#font/Cairo-SemiBold</item>
</style>
<style name="cairo_light">
<item name="android:fontFamily">#font/Cairo-Light</item>
</style>
Now you can apply these fonts either in XML or in .java files like this:
Typeface boldFont = getResources().getFont(R.font.cairo_semi_bold);
textView1.setTypeface(boldFont);
Typeface lightFont = getResources().getFont(R.font.cairo_light);
textView2.setTypeface(lightFont);
for changing the font you can use Calligraphy library here!
it's so easy to use
inside your xml fontPath="your font"
refer to the link for the complete guide

Change the color of the selected TabItem footer

I cannot change the color of the bottom of the selected tab (TabItem) on the TabControl. I need to change from light blue to dark blue as at the top.
I'm using Firemonkey for Android and Delphi XE6.
Open Bitmap Style Designer (see a bin folder of IDE Rad Studio)
In Menu: File -> New -> Android Light Style for FireMonkey (or Dark style)
Expand node "Images". There are a several images for different screen scales.
Look at the style.png. Find a subimages for Tab. Tou can repaint this area. Don't forget, that you need to do it for all images (for all screen scales: style15, style20, style30)
Save style to file.
Styles:
use the following link to help you obtain original default style.From there you can use a copy of the style, and make changes as you wish via dropping a TStylebook and double clicking-> Loading your copied style -> after you make changes, then save and apply.. Then simply change the stylebook property for the form...
http://delphihaven.wordpress.com/2013/12/31/inspecting-platform-styles-redux/
May be theme generator will help you.
Change the style name [now example] and Set your theme, and Just download the zip, paste it in your resource folder, then change the theme in your manifest file, like
android:theme="#style/example"
I hope this will help you.

Font color in string.xml file in Android crashes on older OS

I've created an app in which release is very close. However, I've found that in older Androids (I know for sure on versions 4.1 and older) the color tag in the strings.xml file causes crashes. The tag is changing the font to red.
<font fgcolor="red">Text goes here</font>
There is a lot of text in the app, and some of the strings of red words are embedded in a longer string. Is there any way to avoid this crash? I know it works great on Android 4.4 systems...not 100% sure about 4.2 and 4.3. Any ideas on alternate ways to create red text? Thanks.
Here are some ways to create red text on a TextView. The implementation should be the same (or very similar) for other views.
You can set the text color programatically in the code:
TextView yourTextView = (TextView)findViewById(R.id.yourTextViewId);
yourTextView.setText("Your text here");
yourTextView.setTextColor(Color.parseColor("#FF000000"));
If you want to set this text color in the XML do so like this:
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#android:color/holo_red_light"
android:text="Your text here"/>
If you want to set your own color instead of using androids pre-defined colors, you can do this by creating a color resource XML file and adding your colors as follows:
<resources>
<color name="red">#FF000000</color>
<!-- Add other colors here -->
</resources>

TextView shows in AndroidStudio but not on device nor DebugMonitor

I have a popup which is shown when I receive a GCM notification. The popup is implemented as a LinearLayout which is setContentView'd in the popup activity. The layout render in Android Studio looks like this:
However, on the device and on the DebugMonitor View Hierarchy dump it does not show, although it is there:
The TextView has the default text "Where?" replaced in the extended Activity class:
String lightName = getIntent().getStringExtra(LIGHT_NAME_KEY);
final TextView lightNameLabel = (TextView) findViewById(R.id.lightNameLabel);
lightNameLabel.setText(lightName);
I am at a loss here. I grep'ed through the project files and there are no other uses of the TextView's id other than in the snippet above. Could you please give me some pointers where to investigate why the TextView doesn't show?
[edit] I am including the .xml snippet for the respective TextView:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="#+id/lightNameLabel"
android:layout_gravity="center_horizontal"
android:layout_marginTop="1dp"
android:text="Where?"
android:visibility="visible" />
[edit 2] A link to the whole layout .xml file: http://pastebin.com/2uqkzBSa
It was helpful that you showed a screenshot, as the problem is likely that you're displaying the layout in a dialog. If you select the Holo dialog theme in Android Studio's graphical editor pane, you'll observe that the default text color is white. Since you've provided a light background, the light text is simply illegible against it.
There are different solutions:
Provide a different theme when displaying the dialog as to ensure that the primary colors are dark; or
Define your own theme and provide it when displaying the dialog; or
Modify the layout to specify a text color.

Categories

Resources