This question already has answers here:
Can you set graphical layout preview-only text on a TextView?
(2 answers)
Closed 5 years ago.
Is there a way to have text displayed in the preview pane in Android studio but not in the actual app while running on the phone?
I currently use the android:hint attribute, which is quite useful to see how much space a TextView requires or what size the text will be.
The problem, however, is that in case no text is assigned to the TextView, the hint shows in the app.
Is there a way to have the text display only in android studio but not at runtime?
It's tools:text="some text". This only will be visible in Android Studio.
From docs:
You can insert sample data in your layout preview by using the tools: prefix instead of android: with any attribute from the Android framework. This is useful when the attribute's value isn't populated until runtime but you want to see the effect beforehand, in the layout preview.
For example, if the android:text attribute value is set at runtime or you want to see the layout with a value different than the default, you can add tools:text to specify some text for the layout preview only.
Related
i am new in android development, i want to ask about the meaning of this snippet of xml code android:textAppearance="?android:attr/textAppearanceLarge". Does android framework will determine by itself the size of our text and choose large text relative to their choice?
I have tried to look up from this attribute declaration, but there is nothing that explain the property that will assign to text, and i also confuse by "?android" at the start of property.
I'm following the Building your First App tutorial. I'm using Android Studio 2.3.1
I have default values in strings.xml. When I reference these in the design editor, they show up correctly in the design preview and the XML. However, when I run the app on a device, no text appears. There are no errors or warnings. I've tried multiple devices.
strings appearing correctly in the design editor
This happens because you are setting the string content in the tools text field (the one with the wrench on left). You have to set the string content in the empty field above.
If you set the string content with tools:text, it will apply only to preview layout.
If you set the string content with android:text it will apply both to preview and to rendered layout.
If you set both, the tools:text field will have more priority than android:text field on preview and the android:text field will be used for rendering.
Check those properties again.
You have the string in the text property with a wrench. If you look at the XML, you will see tools:text. That's a text property that you can only see in the preview (to test with dimensions and things like that, like you had real text on the component).
The real text one is android:text.
This question already has answers here:
Why is my Button text forced to ALL CAPS on Lollipop?
(20 answers)
Closed 8 years ago.
I have a simple homescreen widget with a few buttons on it. My problem is that when the widgets are running on Lollipop the button's text are all capitalized, any previous Android version doesn't have this problem. The buttons in the layout.xml are very ordinary buttons: no styling or special sauce, just a width height and text size. The interesting thing is that any TextViews I place into the widget aren't affected by this in Lollipop, ie. it appears that only Button objects have this issue.
My AppWidgetProvider is pretty simple too: just sets the sets the text and a PendingIntent for each button.
It sounds like a global styling problem, but I can't find anything in my application's resources that would cause this. Does anyone have any input to this problem? Thanks!
You have 2 options :
1.Use android:textAllCaps="false" in your layout-v21 (or anywhere)
Programmatically change the transformation method of the button. mButton.setTransformationMethod(null);
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Android eclipse editor: Unable to edit properties
I have changed my computer recently with the last version of Eclipse and ADT plugin and I'm confused.
I have noticed some changed with the ADT plugin and now I can't put specific values in the properties box in Eclipse.
I used to click on a Layout (in graphical View); then I went to the properties box and change one of a Layout properties to a specific value like 50dp.
Now I don't have a choice, I can only select fill_parent, wrap_content, match_parent ...
I order to do what I want, I need to edit xml manually.
Do I miss something or not ?
If you look in the toolbar just above your layout, use the button with a dashed square in it.
This question already has answers here:
Is it possible to have multiple styles inside a TextView?
(20 answers)
Closed 9 years ago.
I am currently working on android project where I want to have a text view that contains two lines of code. I know I can just put a new line character in between to make it on a new line but I want to do a bit more than that.
Basically what I want achieve is on the first line I have text which uses the normal text design and on the next line the text will be styled differently, i.e. smaller and slightly different font colour.
I've tried searching for this and can't find anything anywhere.
Thanks for any help you can provide.
Option #1: Just use two TextView widgets in a vertical LinearLayout
Option #2: Use Html.fromHtml() to convert an HTML representation of what you want into a Spanned object that you can pass to setText()