difference between Editor Fold and Region comments in Android Studio - android

In Android studio there is two option for code folding. one is Editor fold tag (<editor-fold desc="Description">) and one is region comment (//region Description).
I used both for code folding, but never understand what is a different between both?

The difference is in style. <editor-fold..> provides NetBeans folding style and region..endregion provides VisualStudio folding style.
Note:
You can only choose one of the style for a particular file. No mixing should be done.

Related

What makes buttons purple in Android studio? Plus other odd behaviours for a newbie

In web development, I see how tags have default themes defined in the browser, and I see how they're applied.
However, with Android Studio's themes, I'm really confused. I can define my custom themes using ?attr/myClass, apply it on widgets by android:theme="?attr/yClass", and then assign a colour to that attribute in my day or night theme files.
But, what baffles me, is—that purple. Where does it come from? When I set the theme header to
<style name="Theme.TestingThemes" parent="Theme.MaterialComponents.DayNight.NoActionBar">
purples come for the not night mode.
When I use other styles that come with "default" with Android Studio, I don't see exactly that purple.
Some themes allow me to set my own colours, but some others don't, like the one that I mentioned.
Worst of all that totally blows my mind is: when I open the theme files in app/res/values/themes/* and app/res/values/colors.xml*, I only see less than 10 themes defined. Yet I see Android Studio suggesting to me a long list of colour names! Where do these come from?
I only use Vim as my text editor. I'm drowning in Android studio. It's cool and powerful, but I require some baby-walking assistance.
A default new project created in Android Studio has a colors.xml resource provided in the project (res/values/colors.xml), where the purple_500 and purple_700 you described are defined.
Any other colors and themes you see that aren't in your own project's files are in the AppCompat and Material Components libraries (defined as project dependencies in default new projects), or they're built into Android itself.
In the Projects panel on the left in Android Studio, if you expand External Libraries, you can see all the code libraries that are imported for your project as dependencies (these are defined in app/build.gradle and downloaded from the Web automatically). Among these dependencies are AppCompat and possibly the Material Components libraries, with their own provided resources within.
You can't modify the contents of the libraries. You're intended to customize by extending (making child styles and themes).
If you want to see where a reference is defined in Android Studio (in XML or other languages like Kotlin and Java), you can Ctrl+Click and it will jump to the line that defines it in whatever file it's in.
I've been developing with Android for a year and have honestly never bothered using material buttons.
You can create your own drawable file for the background of the button and then add that drawable to the back of a regular button in a layout. Don't let things like this frustrate you; there are so many ways of achieving the same outcome in Android :D

How do I use the full editor screen in Android Studio?

I know it must be a dumb question, but Android Studio has so many options that confuses me. I want to use the whole editor section and not the half as shown in the following link.
https://i.stack.imgur.com/4IYln.png
I'm new into this and willing to learn Flutter. Thank you! ^^
You can set the value for Hard wrap at in the Android Studio Preferences to a value higher than 80. But even very high values won't let you use the full width of your editor for the sake of common Flutter code style. If a line gets too long, you might want to consider breaking it apart to make it easier to read and understand. Or, regarding Flutter, flatten the widget nesting by extracting parts to custom widgets.
You could also use the remaining space to display the file explorer or to view two files side by side.
You are using the whole editor section. That's a hypothetical line that is adviced to keep your codes on left side of it.

How to add design tab to palette in Android Studio

This is what my palette looks like, I want to know how to add other tabs like design and appCompact.
Thank you
I'm not sure I understand what you are asking. The palette cannot be modified and is a container for components such as button, texts, etc.
Please refer to this for intro into Android Development.
AppCompact is a support library that allows for themes, colors, widgets, etc. to run on earlier devices i.e. backward compatibility.
The design view is accessed through the res folder in the layout folder. By default, called activity_main.xml.
You should go through the basics of android development so you can understand the structure, components and overview of android Studio.
EDIT:
See this link which shows you how to create custom view components
Please view this link which goes over the entire overview of the UI and how to use and customise the UI layout design(Very Useful!).
The folks that works on Android Studio redesigned the Palette window in Android Studio 3.1.2. Some of these widgets have been completely taken out.
"There is a new "Legacy" section and the "Advanced" section has gone. Along with it the NumberPicker, DataPicker, TimePicker, TextClock, Chronometer and, as far as I can see, the Transitions category has gone completely along with all its widgets."
"If you rely on any of the missing Widgets then my advice is don't upgrade until a workaround has been made available. There is no word from the Android Studio team as to why these widgets have been removed and no word on how to put them back."

Android radio button style definition

How can I make sure that the radio button appearance for 2 different projects is the same?
I copied what I thought were all of the relevant files and code from one project to another, but the radio buttons (and some other features, like the title bar) appear different. It's like the activity_main.xml file is being interpreted differently, or there's a different set of defaults. They have the same target & min sdk, and they reference the same base theme, and have the same activity_main.xml file.
I'm not sure if it makes a difference, but the original code, that has the look I want, was written on the Android IDE that was available about a year ago.
Thanks!
You are definitely on the right track. My first guess would have been the theme and style used. I do not believe the version of the Android IDE will have anything to do with this. I would look a little bit more closely at the themes. See if you have multiple styles defined based on OS versions and make sure you copy all of them. My only other guess is that the theme or style is being updated in the code in one of the projects.

Why "Buttons in button bars should be borderless" in Android API Level 15?

I'm developing an application for Android and I recently changed the API level target from 8 to 15, and now Eclipse is warning me when the Buttons are inside Linear Layouts or Table Rows.
The same doesn't happen when the Button is in a Relative Layout.
The warning says:
Buttons in button bars should be borderless; use
style="?android:attr/buttonBarButtonStyle" (and
?android:attr/buttonBarStyle on the parent)
I can get rid of the warning by following the suggestion or even by suppressing it, but I'm interested to know why this now? What's wrong with bordered buttons?
The borderless buttons are for cohesiveness of design throughout the android platform. It's recommended you follow the guidelines so that the user feels that your app is native and does not stick out like a sore thumb, but there are many cases where it just doesn't make sense, like if it makes your app look unprofessional. If that is the case, you may want to turn off the warning.
To turn off the warning, go to the project properties -> Android Lint Preferences. Search for "border" or "ButtonStyle" and change the severity to ignore on the bottom right.
You can also do this in Eclipse preferences for all projects.
For Android Studio Users:
File -> Settings -> Editor -> Inspections -> Android Lint. Search for "borderless" and uncheck or change the severity.
Here is another simple way to get rid of it.
The compiler is trying to tell you to set the style of the button. So simply add the following style for the Android default borderless style and the error will be gone.
<Button
...
style="?android:attr/borderlessButtonStyle"/>
Here is the proof
In my case adding that style to ALL buttons which were ONLY elements in some linerar layout gave buttons without any borders. After adding style also to the layout I got buttons separated with small edges exsacly like in some epements of my (4.1.2) android interface eg. like in dialog possitive/negative buttons. It worked correctly. Standard Holo buttons are ugly but with that styles they look "professional";-)
You can add this code to fix it " style="?android:attr/borderlessButtonStyle"/> "
but if your emulator is too old then that problem can occur aswell.Try to change your emulator Pixel 6 Pro.

Categories

Resources