Android- Can we create material views programmatically? - android

Is it possible to create Material Design views (like button, textView, ...) programmatically?
like
AwesomeButton btnTest=new AwesomeButton (context);
i want full featured library like rey5137 but without XML usage and support old android(maybe Android 2.3 and up).

material design is all about different combinations of items in xml. you cannot design without xml. it is not java swing don't forget, whatever you want to design their base should be on drawable or layout folder, not on java code
update for the edited question
in your example, you say AwesomeButton, in order to have something like this, you need to have a library, which also has xml design file including all those fancy visual effects. If you don't design how are you supposed to create a pre-designed button.
chamran, you are making it complicated my friend, you can't design a button via code, you have to have a xml file for your own custom materials. Even the default button has a xml.

Related

Is it possible to add custom interactive UI elements to EditText?

A bit of context here. I'm an iOS developer with no knowledge on Android development.
I need to know whether it's feasible in Android to embed custom interactive UI elements (in iOS that'd be a UIView) inside of EditText.
A library I found to do this in iOS is: https://github.com/vlas-voloshin/SubviewAttachingTextView
You can see a GIF in that link showcasing the kind of behavior I'm looking for.
Is there built in support, or any third party library I can use to achieve something similar in Android?
in normal way this is not possible in android and we don't have any standard component or any library (that i know) for doing such a thing but we can create something similar to this (for this you should search about custom Views in android !) and also there is other way and easier way to achieve something similar to this is using the container layouts in android like LinearLayout and adding all your component to that container layout in run-time base on your text ! for example in your code you can dive in to your text and find tags like or and create appropriate view for your tag and add it to your container layout and at the end your layout looks like that gif wich is in your question ! and also in android we can show some basic html code in textView

EditText XML Design

I'm looking to create an EditText that looks like the following & was just wondering if it was possible & if anybody might be able to provide example XML code to create the following.
Note: The cursor doesn't have to be blue, if it can be that's cool, but definitely not required.
This is just an EditText with a custom background (the underline with the curved shape). You would just use a standard EditText, and add your custom drawable (however you make that - either a PNG, 9Patch, ShapeDrawable, etc) as the "background" element. The text label would just be a TextView you put in your layout above the EditText.
However, I would steer you to use the new "TextInputLayout" provided in the Design Support Lib. This has a ton of built in functionality, and as a bonus, your app will be consistent with Material Design standards.

Is there something similar to Android's XML Drawables in iOS?

I'm currently creating a "design language" for my company which includes custom drawables for buttons, sliders, etc. Basically the idea is that I want our apps on Android and iOS to look and feel as similar as possible.
I started on Android and created XML drawables for buttons with simple borders and rounded corners, etc. Because I'm using XML, I can easily change things like the line thickness, radius dimension, and color with a single change. Other files reference things like #dimen/default_thickness, etc.
Is there any kind of similar concept on iOS? What I'd like to do is recreate these UI elements on iOS "dynamically" so that I don't have to create image files for each element. This would make it harder when one app uses one color for objects and another uses something else.
Basically what I want to know is this: Is there any way, with iOS, to create drawable resources dynamically instead of using static, pre-rendered images?
First,
No there is no XML for adding style to buttons or other views.
Second, you can implement the same type of design process by creating a constants file using NSObject, and then just add custom functions, variables for creating buttons... Something like:
+(UIButton *)create_styled_btn(float corner_width, UIColor color) {
....
return btn;
}
And of course you can dynamically change the style of objects through code, just like in android. XML in Android is of course static, so maybe I'm reading your question incorrectly.
All the best.

Android Spinner Custom?

I am trying to create a spinner that looks exactly like the one in this android example, but not sure how or if it has to be custom? I cant imaging it would have to be a custom layout since it is shown this way in their example...
http://developer.android.com/guide/topics/ui/controls/spinner.html#Populate
I am not concerned with how the list looks, but just the way the spinner looks with the lower corner arrow. that is what I want.
This project is an attempt to backport the holo theme by building it into and Android Library project. You can link that library with your project in order to gain access to the holo theme widgets.
I have never used it but I would think that it contains the spinner widget that you are looking for.

How to make customised android button shown in the below image?

By using css or jquery it's easy to bring this grouped buttons. But in android native application how to design a xml file to bring grouped buttons like this, without using tabWidget method (i.e)tab layout.
That's a segmented radio button. There are various solutions but this is a good one: https://github.com/makeramen/android-segmentedradiobutton

Categories

Resources