I'm trying to do the following:
<com.ophiropt.meissa.view.SwitchCompatNotify
android:id="#+id/trigger_switch_channel_b"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:checked="false"
android:text="#{#string/channel+ #string/b}"
android:textColor="?attr/colorPrimary"
android:textSize="18sp"/>
but I don't see any text near the switch if I write a "hard-coded" text like:
android:text="channel a"
I see the text near the switch without any problem,
is this a bug of Android?
how can I get it to work?
(I can't put there a hard-coded word because I need it to be translated to 5 languages )
any idea?
Thanks!!
the problem wasn't with the SwitchCompatNotify by the end,
the problem was with the inflating of the dialog that contained it.
we can have a text like this: android:text="#{#string/channel+ #string/b}"
only if the dialod is using data binding,
and in this case the inflate of the dialog was a regular one without using data binding(DataBindingUtil.inflate), therefore it didn't work.
Related
I need to show SmallCaps text in TextView. I am trying to use code below:
<TextView
android:id="#+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFeatureSettings="smcp"
android:textColor="#color/black"
android:textSize="16sp"
android:text="TEXT" />
But it just shows me normal text, without SmallCaps effect. I also try to set it programmatically (text1.fontFeatureSettings = "smcp") but also without success.
How to make SmallCaps text in Android? Why fontFeatureSettings doesn't work?
In order for this feature to work you have to have a font that actually has Small Caps characters - thus to make it work pass the font with Small Caps via app:fontFamily(android:fontFamily) for example Aller Display, and then use android:fontFeatureSettings="smcp" to make it Small Caps.
Hope it helps
Edit
as #Cliabhach pointed in comments, in code it will look something like
text1.typeface = resources.getFont(R.font.Aller_Display)
text1.fontFeatureSettings = "smcp"
Edit2
Keep in mind
For those who do not know - Small Caps will only work on lowercase characters
As you are using TextView so I guess you set value to it at runtime like says you have some String object which will get set to the TextView like:
textView.setText(someStringObj);
So you can easily set it as in lower case on it by adding:
textView.setText(someStringObj.toLowerCase());
After some time my xml files declaration are changing. sometimes when I open it my textvalues are changing from my #string values to regular texts. In this case:
android:id="MAC Adress" Can someone explain why?
<EditText
android:layout_width="330dp"
android:layout_height="wrap_content"
android:hint="#string/mac" <!-- <-- THIS -->
android:id="#+id/editText_mac"
android:maxLength="17"
android:paddingLeft="15dp"
android:paddingRight="15dp" />
it is a nice feature of AndroidStudio. It shows the content pointed by the id. But you are still using the reference to the localized value. As matter of fact, if you click on the text, you will see again #string/ instead of the value pointed by it
try clicking on it, you'll see the previous string path. It just hides to make it clear and easy to access the string , instead of the path to string. It's the same with every one...
What is the meaning of this warning?
No label views point to this text field with an android:labelFor="#
id/# id/editText1" attribute
Note that the double id (#id/#id) is a problem with the error message text and does not reflect the XML content (which is the correct syntax).
The labelFor is an attribute for accessibility options. You assign this to a label so that if, on a form , user clicks a textedit field , android can know what to read (TalkBack) to user.
The id you assigned to it doesn't seem to be a valid one. why there are two #id in the id? Use ids like this: #id/editText1
I've had the same warning message. It disappeared, when I added a hint to my EditText
android:hint="Some explanation about the input..."
Although I am not familiar with the exact error you have posted. But it definitely sounds like you have done something wrong with the id in the textView. Use id like following in your textView.
android:id="#+id/editText1"
And if you want to set labelFor then use :
android:labelFor="#+id/editText1"
It means that you probably should define a label for this edit text and link them using a labelFor inside that labels definition.
example code:
<TextView
android:id="#+id/my_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:labelFor="#+id/my_editText" <!--the plus sign goes first in the code-->
android:text="I'm a label" />
<EditText
android:id="#id/my_editText" <!--no plus sign if not the first-->
android:layout_width="wrap_content"
android:inputType="text"
android:layout_height="wrap_content" />
and it's not only for text views.
Remove th first '#id/' , use like
android:id="#+id/editText1"
which is the correct format. Keep going.. Best wishes.. :)
I solved it by writing both attributes:
android:id="#+id/editText1"
android:labelFor="#+id/editText1"
Select the editText, go to Properties, then Label for and enter #id/EditText1
If the XML looks correct and you're in a Graphical Layout mode then it's probably using a later version of the Android rendering layout that doesn't support EditText.
In Eclipse and Android Studio there should be a green Android icon with what API version is rendering the layout. Make sure you're using a non W or Wearable API as Android W APIs don't support the EditText element. (EditText is most likely not supported because virtual keyboard space is limited on those devices).
The rendered preview should support EditText in any API 4.X version without a trailing W.
Can some one help me, I have heard alot of things and I dont know what to believe. I am making an app that is a counter. In my xml layout i have a TextView acting as a counter and the text is set by a string in strings.xml and i am controlling what the text view says from my java file. here is some code snip its. all I want to know is this ok?, it works fine but I want to know is it a bad or good way.
"counter" equals a variable.
"display" is referencing the ID of the textview"
what i am using to control the text view.
display.setText(String.valueOf(counter));
here is my text view in my xml layout
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/tvDisplay"
android:gravity="center"
android:text="#string/counter"
android:textSize="20dp" />
here is the string in strings.xml
<string name="counter">0</string>
It's fine, that's how you change text dynamically.
Yes, All things are right and good. Yo should have to give the String Value as like that.
If there is a Small Value of TextView then you can directly give as android:text="abcd"
And If you want to give any reference of that then your code is also correct and works as well.
For the Best use of coading your should have to try as like you have done rightnow. as Because it helps you a lot if there are number of TextView and you want to manage or change the Value of it quickly.
Enjoy. :)
Thanks.
In a a custom list view, I have a textview showing name and emailId. When the name provided is something like A-TestThisString(testA#test.com), the length of displayed area exceeds,
In that case the string is broken at the place of hyphen like
A-
is shown in the list. This is causing lots of problems. I have found one link which talks about solution bellow
topic: "Android: How do i make nonbreakable block in TextView?"
but, I am not able to understand how to use it. Please suggest.
Thanks for your help. I found the answer. use the inputType as email or singleLine=True, it starts working fine.
I used android:inputType="date", no line breaks and hyphen is displayed nicely
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="2-3 4-5"
android:inputType="date"
android:textSize="25sp" />