reusable UI in android app - android

I am working on android app where I am thinking to develop reusable UI interface. How it can be developed and included in my .xml's
Here I want to develop a progress bar with my image and it will be display on some .xml's.
Please provide any code help.
I am a new in this field.

you can use <Include> xml tag within your layout xml,
read this :)
http://developer.android.com/resources/articles/layout-tricks-merge.html

I think you need to use styles and themes. Check this out.

You can either build custom (compound) views, look at Building Custom Components.
Or you can use Fragments. Fragments are new in Honeycomb (Android 3.0), but there is a compatibility library that adds fragment support to lower android versions (can be found in your ANDROID_SDK/extras/android folder). Or you can mix both of course.

Related

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."

Equivalent to UserControl in Android with the MvvmCross framework

I would like to know if there is any equivalent to UserControl in Xamarin.Android using the MvvmCross framework. Because I have a MvxActivity containing a layout I would like to reuse in several Views. And I don't know how to call it in my these several views.
If you have any idea...
Thanks for any help !
You could try the MvxFrameControl at the end of N=26 in http://mvvmcross.blogspot.co.uk/
The source code for MvxFrameControl also shows you how to inherit from any Android control in order to add data-binding capabilities - see https://github.com/MvvmCross/MvvmCross/blob/v3.1/Cirrious/Cirrious.MvvmCross.Binding.Droid/Views/MvxFrameControl.cs

How to set alignment for layout in android with localization?

I have used localization in my android application. Which supports two kind of layout in application.
I have used Fragment and Fragment Activity in my application.
If language is English then layout should be aligned to left as shown in image below.
And if language is Hebrew then layout should be aligned to right as shown in image below.
I am trying to load this layout by two different layout files and then I can detect which language and I can use appropriately.
Is there any other good methodology through I can use achieve this functionality without creating different XMLs for all layouts?
Can anybody please help me to resolve this issue?
This should help:
http://developer.android.com/about/versions/android-4.2.html#RTL
Android supports right-to-left layouts natively since android 4.2.
Creating two similar layouts those are having same #+id values is a clean approach but if you don't want to create two different layouts then you could simply set the layout_gravity attribute by code with some helper method and by getting the LayoutParams of the containers you are using in your xmls.
Edit :
From another answer , If it works for you with the support package i.e. v4 if you are targeting 2.2+ above then this would be an awesome approach to go with.
http://developer.android.com/about/versions/android-4.2.html#RTL
just came to know about this. Android is awesome!!

Android GUI Layouts in Eclipse

I am very new to Android development and am having some trouble. I am creating an XML file using Eclipse, both the Graphical Layout feature is what I'm having trouble with.
Also, I am working in Android 2.3 for compatibility reasons.
I am wondering if there is a layout which enables me to place buttons or text fields or any attribute where I want to put them. This may sound stupid, but it seems that every layout has some sort of order in which it lets you add attributes, and whenever I try to drag them elsewhere on the layout things just get very very messy.
If what you want is an AbsoluteLayout, this has been deprecated since Android 2 (IIRC). You can try using the RelativeLayout, which let you position freely your widgets. Else, if you only use LinearLayout, then yes the widget will be positioned in a strict way.
use Relative Layout. I recommend that you read up on Android layouts so you understand why, what and hows of Android way. There are some good tutorials that I found helpful. TutsPlus: Android Layouts
There is also a very good video from Marakana.
Marakana: Android Bootcamp
If you are just starting out with Android check other tutorials/videos on Marakana. They are a very good resource for beginners.

Which is best, Java or Xml for developing android apps

I have know core java, I want to develop android apps, in few sites I saw apps in XML in few Java.Which is best and easy to use Java or XML?
I'm assuming you are talking about the UI, not the complete app:
For everything statically I use XML, because it is easy to find in the structure of your project.
Some parts you want to create dynamically and you have no other choice then to use Code. Be smart, in this, so if you have to add several Views that look the same do this
Make an XML with your views
In the loop where you are adding the several Views, inflate this xml, set your id's etc, and add them
You can have all the basics, styles etc in your XML, and still add stuff dynamically.
Maybe you want to check out some of the hello world code?
You can't build apps in XML. You use XML to define the UI and a few other things, but the logic of the app itself has to be written in Java.
Android development is in Java, but when you declare the layouts (where the buttons and so are going to be on the screen) you do that in XML.
So you have to use BOTH anyways.
XML for layout
JAVA for programming your app

Categories

Resources