I have this layout xml
does order matter?
I mean what will be the padding?
what would happen if the same attribute repeat twice? compilation error?
4,4,4,0
or 4,4,4,4
or non deterministic?
As for already existing attribute, you cant use the same attribute more than once in the same XML tag.
If you do try to use the same attribute twice you will get “duplicate attribute” XML error.
I'm sorry, I completely miss understood your question in my previous answer and made a mistake myself.
I'm not sure where you can find this in the android docs, but from my own experience you cannot provide the same attribute twice (this would lead to a compilation error).
To update my previous answer (I've edited this post to get rid of it, so I don't confuse or mislead any one), with the padding example I gave, padding overrides padding-top no matter what order you put them in.
Also I'm sorry for the slow response, I've been away for a few weeks and only just got back. I hope you found a better answer before I updated this post and I'll be quicker to clarify anything if you want me to.
Related
I have an app, where some fragments only consist of ListViews. Some of my users with low-end devices experience a phenomenon, where a fragment simply can not display the data. When they enter the fragment I display a ProgressBar, and this ProgressBar seems to spin forever.
So I bought a low-end device and am facing the same problem. I get the data for the ListView with a network request to my backend API, but the answer is never returned. The only warning I see so far is
W/ResourceType﹕ Too many attribute references, stopped at: 0x01010034
I could not find much about this error in the web but it seems like this warning is logged here https://github.com/SciAps/android-frameworks-base/blob/c693209edc3696884c1fcd59790dda0b9811d017/libs/utils/ResourceTypes.cpp#L1573, but I don't understand what the Android code is doing there.
Anyone has a clue about what's going on here, what's the problem and how I can fix that?
BTW I use RoboSpice and Retrofit to do the network requests. The background service that is responsible for getting the data is stopped after this warning, that's why I never get back data.
EDIT As far as I can tell not seeing the data has nothing to do with the warning. Anyway, what does this warning mean and how can I prevent it?
I accidentally applied a style as a theme on a view, which resulted in this warning showing up. In the view's XML, by using style="#style/MyStyle" instead of android:theme="#style/MyStyle" I was able to stop the warnings.
Actually, the most upvoted answer by #Corclark was not entirely accurate in my case. I got the same warning, but didn't have the style="#style/MyStyle" set anywhere. I experimented a bit and found out it was actually this line that caused the warning for me:
android:theme="#style/My.Switch"
Then, I found this answer. Changing the style of My.Switch to
<style name="My.Switch" parent="">
<item name="android:background">#color/dark_grey</item>
<item name="colorAccent">#color/Unpluq</item>
</style>
resolved the warning for me. Hope it might still be helpful to some.
It happens when using ContextThemeWrapper for creating new ElementViews
TextView txtView= new TextView(new ContextThemeWrapper(context, R.style.styleName));
I am working on a simple android application in eclipse IDE and I got a little yellow icon on the left hand side of a line of xml code that looks like a light bulb with an exclamation mark beside it. When I hovered over, it says "[I18N] Hardcoded string "input..., should use #string resource input". The running and debug was successful but I just want to get rid of it as I find it annoying. What should I do?
If it's annoying, there is a reason. You totally should use #string resources instead of your hardcoded strings. All you have to do is to put your string in res/values/strings.xml and reference it in your layout via #string/my_string_id_here.
This is extremely useful for multi language support, or for plurals strings.
You can learn more here.
Hope this will help you.
The right way:
Move all your strings into resource files, as suggested, and reference them in your views like so: #string/mystringname
The "other" way:
Turn off Lint warnings in Eclipse in Window/Preferences/Android/Lint Error Checking
Both ways will remove that annoying triangle :)
This warning is there because hardcoding strings into the android app's Java source code is not recommended. It will compile fine - but Android Lint will complain about it, so that's why it's a "warning" and not an "error". Generally, it is preferable to define them in the separate "string.xml" file.
If you want to know why, check this answer.
For an example, check this answer.
You should also take a look at the official documentation for string resources.
'Entry Identifier 0x11a is larger than entry count 0xb2'
This is what's printed in my LogCat when switching to a specific fragment.
I think it may have something to do with my 'xml layout' resource being inflated. I am not sure what though.
My Question
Has anybody else had this problem or know what it means?
Thanks for your help
I've encountered this problem and worked around it with a hack. I added an empty style at the top of my styles.xml:
<style name="empty_style" />
According to this discussion on Google Groups the error occurs
...when HistoryRecord over in the framework is trying to read the theme defined in your resources. There isn't anything wrong with the code [...]. In fact, if you fiddle around with the ordering in your styles.xml, usually adding a few empty blocks near the top, might help get around this
temporarily.
I can't say if the cause quoted above is real, but it removed the issue for me. Hope this helps.
I am curious to know if there is anyway I can remove OR change the drop-shadow like effect that android gives below a Tab layout.
As soon as I ask this question, I get the answer in another stackoverflow post. Anyways for the benefit of people who have landed on this post, the answer is to
use a custom theme with its windowContentOverlay set to null
I read with interest user sunit's answer to this question about updating an EditText's hint but have been unable to find any documentation on using the method that I presume he appears to describe there: using the <selector> element in an XML layout to dynamically adjust attributes of an EditText at runtime when the element is focused/unfocused.
In my case I am actually more interested in adjusting the android:inputType element (because the hint disappears for me when the inputType is specified) but adjusting the hint would work just as well.
To be clear I know how to make this change in Java code--I'm trying to find out if there is a way to specify the behavior in XML. Thanks!
I'm afraid it isn't yet possible. <selector> is only valid to be applied in making state lists out of Drawable and Color resources, it does not yet work for Strings.
With regards to your mention of adjusting android:inputType to make the hint disappear, this is actually a known Android bug that will eventually be fixed in later versions so I wouldn't recommend building your code around this functionality as it will break when they fix it:
http://code.google.com/p/android/issues/detail?id=13895
Since you mentioned that you already know how to do this in the Java code, I won't point out how to call setHint() from within a OnFocusChangeListener ;)
Cheers.