I am trying to understand the difference between the above 2 styles. It appears after reading various posts the correct way of doing this is assigning the holo theme in the manifest and then doing
style="?android:attr/borderlessButtonStyle"
but it appears you can also do this
style="#android:style/Widget.Holo.Light.Button.Borderless.Small"
which one is correct? Is one an alias for the other?
I must admit the second 1 seems easier to read and understand, its pointing to an internal style - right?
and the 1st one? this is a style or just an attribute within a style?
In the 1st one it also starts with a question mark, what purpose does this have ?
anybody have a good insight into this ?
which one is correct?
Both/either, depending upon your objective.
Is one an alias for the other?
The first one says "there's an attribute in the theme that will indicate what style to use here". The second one says "use this style".
Related
Is it possible to remove a feature (autocorrect, in this case) across the entire app from every single edit text by running an extension? Our app has a lot of edit texts across several activities and I would like to avoid running over each file to hit every one just to avoid adding a line of code, if possible. I have a style set up for that each one is connected to and tried adding
<item name="android:inputType">textNoSuggestions</item>
But that didn't do anything. Some of these fields do have input type set to be just number, and others I set for things like textCapWords or `textPersonsName' and things like that. I believe I made sure to give each one some kind of input, so is it because of that that the style line wasn't working?
I'm aware that I can just make a custom edit text and apply that to each layout file, but that would defeat the purpose of not running through each file.
tl;dr - Is there a way to remove autocorrect across every single activity without editing each layout file?
E.G. #FFFFFFFF OR color/white
Is there any difference/affect in performance on color redraws? Pros/Cons ?
I have asked a few android theme developers and some say that using the #FFFFFFFF recommended as its basically telling it how it is, rather than using the color/white which is to call from another location.
Though I have asked then why in say for example Android Framework/res/values/colors, both formats are being used ?
Is there any difference/affect in performance on color redraws?
Pros/Cons ?
not really.
#color/white
retrieve an entry in your colors.xml file, that contains the colours in the hex format.
#android:color/
retrieve an entry in the colors.xml file provided by the framework
Performance reasons, no.
But, you will likely want a combination of the two. You will define color/white in your styles and in the styles you will set color/white to #FFFFFFFF.
The reason for this is that you can reference the same white color that you defined in the styles everywhere in your app. So if (when?) the day comes that your designer says "I don't want pure white anymore, I want a creamy off-white" you can just change the color in one place and you're done. And if the name is no longer representative of what it is, you can do a global rename with just a few keystrokes.
#FFFFFFFF will make you have control over it.
color/white will have android/samsung/htc/lg control over it; they can override it with somewhat white or greyish in framework.
So, it depends if you want it to be in sync with the white globally in the users framework or not.
At the moment im using:
android:theme="#android:style/Theme.Black.NoTitleBar"
Which I'm growing a bit bored of, Is there a link you can direct me to that shows me examples of all the inbuilt themes and their names?
I read on another post that there is quite a few so it would be best if there was a website/other source that could show me some previews :)
Thanks for the help!
Your IDE (I know Android Studio does), should show you them.
Otherwise, here they are in raw xml form. https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/res/res/values/themes.xml
More information on Android Dev docs: http://developer.android.com/guide/topics/ui/themes.html
You can see all the theme names in the manifest.xml. For this see the following snapshot:
Android Studio has a Theme Editor which provides preview function.
User can find all built-in themes inside.
2 ways to open it:
Open a styles XML file, for instance res/values/styles.xml. Then click Open editor near the top-right of file-editing window.
in top menu bar Tools-Android-Theme Editor.
I'm pretty noobish with it all but basically I think there are only two themes. Day/Night and Light. You can select individual parts and change them but as far as I can tell there are only two themes.
As I had a comment that said this doesn't answer the question I will add that you can use Theme.AppCompat.DayNight or Theme.AppCompat.Light in the AndroidManifest.xml or in styles.xml and edit any individual attribute but there are about a million attributes and god only knows what they all do. In my opinion it's a massive oversite by android.
I'm currently developing an app which should be totally customizable by endusers. Imagine the application has many activities with some TextViews, Buttons, etc.
So the client can create a XML file like this one:
<style >
<h1>25dp</h1>
<h2>30dp<h2>
<actionbar>#cecece</actionbar>
</style>
As you can imagine, for example, there are several TextViews which are always "titles" so they should always take this h1 value.
I know I can parse this XML file and for each textview, apply this style manually, but this is not a good way of achieving this because if I had 3000 textViews, I should manually edit them all.
What I want is to "edit" the actual Style programmatically.
Any tip?
You can't access a resource file in the created APK as they are compiled into it. So your idea to "customizable" styles works only in the following scenario:
your app is a library project
your client uses that library project and create a style which extends/overwrites your own style and compile that into a new APK
You are not clearly telling us if the "enduser" is a user of your app/apk or a customer that can do the above mentioned modifications.
An alternative might be to create your own extensions of TextViews, Buttons etc which can load your style set. You need to create your own style language for that and you need to make sure that the custom views understand and apply them.
A lot of work, if you ask me... I would, in general, suggest to make different themes so that the customer can pick the best suited for them...
Just start developing with android and think instead of reading a book a webinar could be better because a webinar could also teach me short ways and how an android developer thinks when writing the code but now got a problem
<CheckedTextView
android:id="#android:id/text1"
android:checkMark="?android:attr/listChoiseIndicatorMultiple"
</>
I dont understand the above code up to now see lots of different id definitions some of them was for resources and start with #resource/name, and some of those id definitions was like #+id/name just for creating a new id for the component but this time it is using android:id/text1 and I dont understand why it is using it in that manner
Besides, the checkMark thing make me confuse more what are all those ?android:attr/listChoiseIndicatorMultiple means?
Could you please explain me and show me some resource where can I find all those magic attributes so I can cope next time by myself and hope someday can answer other newbie questions
Thanks a lot in advance, and all comment will be appreciated.
Well, reading the docs has always been helpful to me:
Android Developer Site
XML Layout specific docs
#android:id/text1 is just a format used when the id has been previously defined. When you put a + in there that means the framework should create the resource id if it doesn't already exist.
It's normal to use #+id/thisid when defining a new view in a layout, and then use #id/thisid to reference the aforementioned view from another part of the layout (say, in a RelativeLayout where you need to tell one widget to be below another).
A question mark before the ID indicates that you want to access a style attribute that's defined in a style theme, rather than hard-coding the attribute.
#android:id/text1 basically this is used when you create any android component like button, layout, textviews etc.
but when you need any external component which is general for different platform like any color, image etc then you can declare it as #resource/name.
actually there is nothing different just keep one thing in mind that in #android:id/text1, id will simply work as an class name will contains other objects like textview, imageview or any other.
now if you declare #resource/name then in that also instead of id class name will be resource. actually when you will use it in java then these(#android:id/text1) will be converted into object hierarchy.