I am trying to make a button programmable way (no attributes on LinearLayout).
In other words, button count on the View is dynamically.
How to make it ?
Thanks
Take a look at this article it demonstrates creation of Android UI in java code rather than using the declarative approach
Related
I am starting to delve into Android Development and there is a lot of material online. The question is... What are the pro's and con's against the drag and drop XML design method vs coding the view manually? The only reason I ask on here is because online the views are mixed and they don't really back up what they're defending.
If I use the drag and drop method will I have issues further onto my development adventures? That is the thing that worries me the most... I don't want to learn the drag and drop method and then editting the XML to cater for my needs and then be handicapped by it.
For the beginner(s), I highly recommend not to use Drag and drop. We need to understand XML, to be comfortable with android widget. Understanding XML will come handy in future when creating custom styles and themes.
Here are few pointers before you dive in android XML layout
Try sticking with match_parent and wrap_content while defining android:layout_height or android:layout_width if possible
Make sure you have good understanding of RelativeLayout, LinearLayout and FrameLayout and how its child views are arranged.
Forget about ConstraintLayout, AppbarLayout and similar advance layout at current.
Try exploring TextView, EditText, Button, ImageView and ProressBar as far as possible.(This are most common widgets/views)
Try avoiding any tutorial related to ListView, its deprecated. Try using RecyclerView instead, it is one of the important widget that would be used in regular basis.
i'm creating an app, and i'm kinda knew in android develpment, i don't have much experience, but i've bee maneging well. My app is almost complete and now i want to improve the looks.
Anyone knows how to put the widgets inside boxes, separated from background ? Like, i'll give you an example:
Anyone knows how to put the widgets inside boxes, separated from
background ?
=> You can use the CardView provided in support library. CardView is nothing but a FrameLayout so you can include whatever views inside it!
For more reference, go through the Creating Lists and Cards.
Use frame layouts for the boxes.
I am trying to make android application which display newsfeeds through web,I have done with all functionality, as I programmed well but not design well I am getting problem to desing UI of my Application,I donot have enough idea how to do this, whether I use relative layout,or linear layout etc, Would you suggest me the way how can I design UI in xml file, I would be very grateful to you
Use the UI Guidelines from Android Dev site. Take the trainings provided there if you require. Read the Quick Overview page as well to cover important aspects.
... and here is a resource listing page for further reference.
First you have to learn android layouts. Try with some examples on each layouts. People here can help you if you have any issue with layouts, but don't expect someone to design and code for you.
OK . I would suggest you to use these layouts for this screen
Use ActionbarActivity with menu items ( action icon)
Search view or Edit text
Image view
Text view
Vertical Linearlayout with Imageview and Text view
Grid view with text view items.
good afternoon
How could I get a design like this in my android application?
http://s2.subirimagenes.com/otros/previo/thump_7851660img20120718wa0000.jpg
That is, divided into three areas with different background color to the background activity. And for example in the first zone instead of having these options has a TextView and edit text where you enter something.
How to make something like that image what kind of layout is more recomedable use? Linear, Relative ...
Thanks in advance
You could use a fragment layout and use fragments to get that layout
The best way is to use PreferenceScreen with three PreferenceSections.
I currently have a layout that has scrollviewer as main layout, and a relative one (with a lot of views) as my app layout, but now I need to make tabs, the android tutorial instructs to make the actual layout of each tab programatically, how do I convert my current layout (xml) to a class? Is there any guideline to follow? how do I set the relative layout inside the scrollviewer and how do I specify the "android:layout_below="SOMETHING"" and all that properties?
I din't understand your question very well but, when creating the TabLayout programaticaly you define the activities that are used for each of the tabs. Each of them should have setContentView( 'activity layout')
In order to access XML elements in Android you need to do something like the following:
Button submitButton = (Button) myActivity.getViewById(R.id.btnSubmit);
Then you can call things like submitButton.setVisibility(View.HIDDEN) to hide it, or whatever else you need to do with it.
This should work for any layout elements.
Make sure you do this in your onActivityStart method, or else you will throw runtime exceptions.
There isn't any way to automatically "convert" an XML layout file to a class, unless you're using an XML parsing algorithm of some sort, which sounds like way more than you're trying to do.
Hope this helped!