So I'm trying to configure in Settings--> Code Style --> XML how I would like the order of the attributes to be sorted when reformatting the code using ctrl+shift+L on Windows.
In my case, first all xmlns and other namespace attributes and then all the specific views attributes.
In order to do so, I tried playing with the rules preconfigured in the code style settings, and also by creating new rules.
By default, first xmlns tags are shown, then view attributes, and then tools:..., as shown in the image here:
When going to Settings--> Code Style --> XML, I tried playing with the preconfigured rules and even tried creating a new rule, but didn't manage to get the tools:... attributes to be displayed after the xmlns attributes.
This is an image of the code style settings screen, also with the rule, I tried to create.
Just to make sure, this is what I'm trying to achieve:
I also trying going over and over the documentaion but couldn't quite figure out how to properly create the rule, since it's not working.
XML code style documentaion
Has anyone tried changing these settings, and/or can help me with the setting?
Thank you
Found the answer:
1. Add a new rule
2. In my case:
Name = tools:.*
Namespace = .*
3. Done!
Related
I am very new to app development and I am facing this error in issue panel in android studio
Failed to find '#attr/shapeAppearanceSmallComponent' in current theme
i am also facing a warning
Missing styles. Is the correct theme chosen for this layout?
After searching on web i found that this is caused by the wrong theme selected in AndroidManifest.xml.
So as i can understand this:
There is a file for every theme and have some values defined in it.
Theme is defined in AndroidManifest file, is a way to tell compiler that theme related values are saved in given file.
For me i have selected wrong theme file and my app is trying to find an attribute #attr/shapeAppearanceSmallComponent which it can't find because it is not available in theme passed in AndroidManifest.
My app want this attribute as i am using something which need this to be defined (maybe like material TextInputLayout).
Still this is my theory, i am no where near any answer
Now things i want to understand.
: Even if there is a problem in my application, i am still able to compile it and deploy on a device and it is running fine, In which case i can have issue because of this error.
If my theory is right than i have few questions:
If i am using some element (Button or EditText), how would i know that which theme does it support
What if i want elements from different themes to be used in a single application.
One more thing i observed is that in drop down menu in design view for activity_main.xml after changing the theme to Material3.dark from MaterialComponents removes the error.
error image
no error image
If i change theme in design layout using drop down menu it won't change automatically in Manifest file. So will it be true to say that changing themes using that drop down menu is just telling me, how my app will look using that theme, and if it is showing an error i shouldn't use that theme and use one which is not giving any kind of render error.
I will post my AndroidManifest or my activity_main if required
I'm developing an app with different brandings that do share the same codebase for most parts. In my android project, I got a xml file for every branding containing the colors. Every view used the color codes defined within these xml files instead of using 'hard coded' color codes.
I would like to achieve the same thing within iOS. How can I do this? I would prefer a solution that does not involve dragging all references into the view controller and set colors via code. Is this possible with Xcode?
Please click on a view and check for Background.Click on dropdown and check
other... is present , click on that now follow the screenshot attached.
I'm learning to develop android apps and in the process I realized that there two ways to get a job done. Using xml or normal code. Suppose I want to change the position of a button, I'll be doing it in xml using align left/align centre etc., This will be done in the XML file. If I want to achieve the same through code, where should I place the code ? Inside which class ?
There are two aspects to your question that I understand.
1. Creating a whole layout file dynamically (without XML).
2. Creating a layout through XML and changing the components positions and properties dynamically through your activity file.
Now, it's upto the developer what he wishes to choose.
To help you further, please view this video link posted by the Android team.
It's all about layouts and includes how to layout apps using Java, not XML. However, you are warned that the android team wants you to use XML.
The code will be placed in the same class as the class where you reference your xml code. Do a read up in your android docs for insight.
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...
I am using this tutorial to try to replace the default TitleBar with a custom ActionBar. I am to the part where I am trying to create the xml layout for the custom title (#2 Under INCLUDING THE ACTIONBAR WIDGET IN YOUR APPLICATION), and the tutorial defines the ActionBar in the xml using
com.thira.examples.actionbar.widget.ActionBar
I have no idea how to figure out what to put there for my ActionBar. I believe this is called the package name. If so, how do I figure out what mine is. If not, what am I looking for here?
There are a couple options for figuring out your package name. The first (and easiest) is to declare it yourself in the project properties dialog:
Alternatively, if you haven't defined it yourself you can take a look at the AndroidManifest.xml file that is generated as part of the packaging step of the build. You can find it in the obj/Debug/android folder of your project.