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
Related
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 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 was reading the tutorial on Styling the Android toggle button here. The author asks us to create the 9patch drawable for both. I have trying to do this all morning, but have not been able to. Could anyone share the images with me, or tell me where i can get them ?
Kind Regards
You can find the 9patch drawable tool in the SDK folder in the tools folder.
It's a very useful tool for creating 9patch images, and you should be able to make your toggle button with it
There are links to 9-patches here: https://stackoverflow.com/a/15640365/2066079
The ones provided will style your togglebuttons to look like switches (which are only available in v14+)
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
When I place things like text boxes they are fixed in one position and I can't move them around easily.
How can I edit the style and maybe put an image at the top of the text boxes and give the app a neat and pretty little layout?
Thanks
Use RelativeLayouts instead of LinearLayouts (i assume that you are using them) which allow free positioning.
To modify the theme/colors, read Applying Styles and Themes.
Create 9-patch graphics and assign them as backgrounds.
I am unsure if this is what you are looking for,but you can arrange the object on the layout from the xml files in res/layouts/ folder.Do not forget to follow the UI guidelines provided by google for android development. Also you can create custom themes for you app if you do not like the default template.