Android Custom Button Drawable XML File - android

I recently discovered that you can describe an Android custom drawable in an XML file, which you can then use with a button (and other View, I guess), and this inspired me to ask this question:
Does anyone know (or know where I can find) an XML file that precisely describes the exact default button that shows up in an Android application if you don't change a single detail.
It seems to me, that would be a very helpful starting point.
Thanks,
R.

//this is an nice tutor for gradient
This time, all those gradients are created programmatically which gives you total control of the button and the gradient!
link here:

The default Android Views, like Button, and its selector XML files are available in resource folder of particular Android platform.
For example,
\android-sdk-windows\platforms\android-8\data\res\drawable folders.
These drawables and XML files are accessible in our application code, using 'android.R'.
For example: android.R.drawable.btn_check

Related

AndroidStudio Adding an image to draw with srcCompat

I am trying to do a drawer activity with Android Studio and I'm wanting to personalize the icons used. I've downloaded the icons I want to use and for the most part, it's okay.
In fact, I can modify all the android:icon icons but I have no idea how to modify the app:srcCompat icons. I don't know how to detect the image I want to use in this case...
Do you know how I can do it? Could you explain this to me?
Thanks a lot!
Edit: The file I'm working on as a base is the generated project with Drawer activity as the main activity. For example, if I wanted to modify the icon in the nav_header_main.xml file, how could I do to have my image (.png) transformed in a way detected by Android Studio as compatible with srcCompat
Ensure your image file is in res/drawable folder(or drawable-xhdpi/xxhdpi, determined by your design)
Refer it by app:srcCompact="#drawable/$IMAGE_FILE_NAME" in your xml.
Then you should see what you want.
Please check the doc to further understand the official usage.
Well... I was blind! I was wondering how I could add my icons but they were, I was just mistaking on the address... #android:drawable/... is obviously not #drawable/... but I didn't notice. So be aware that there is a difference and it'll be okay I think!

iOS equivalent to androids colors.xml

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.

How to customize android widgets

Hi I am a beginner in android and I want to know how to customize buttons,check box etc., I searched in web but found many ways and got confused...
Can you please tell me what are the ways to customize android widgets, can we do that using css, like we do for the HTML?
Thanks in advance...
There are a few ways. You can use 9patch to edit the files inside the SDK(which will typically be C:\Android\SDK\platforms\android-19\data\res\drawable-hdpi) - Android-19 is the api level, and then set them in your xml layout under the widget you want with
android:background="#drawable/your file"
Another way is to create a selector(Recommended because it can handle stuff like when clicked and more), shape(Simple creation with corners and stuff), layer list(Advanced selector) or solid(just a color) in /drawable and then set them in your xml under the widget you want with
android:background="#drawable/your file"
An example of the second solution can be found here android button selector

How to set up a layout using code and not XML

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.

android: activity creates xml files

Is it possible for an activity to create xml files and write inside?, or just modify an existing xml files in the res folder?
i am trying to achieve an activity which the user can design a live wallpaper inside it, than save it into an xml file of sort, or modify an existing one (which could be better), and the wall paper service will read that xml file to apply it to the screen.
It a bad practice to modify your code at runtime, moreover I don't think is even possible. a possible solution is to create a default layout, and then modify it using java methods, in case there are not method you should extend the View class of the object (button,imageview...).the following question might be helpful for y
Android Runtime Layout Tutorial
Perhaps this would help
I haven't worked with XML but I doubt it is not possible.

Categories

Resources