Accurately placing text in activity - android

As part of the android app I've been asked to write, there is a 'contact us' activity. This activity is supposed to have the company logo at the top, then various contact points (accounts payable, HR, etc) on the left (one on each 'line') with the corresponding number aligned on the right.
I've spent quite a few hours on attempting to use different layouts and placing them in the XML but it looks terrible.
What approach is best to solve this? It needs to look reasonable on both phones and tablets.
TIA

See Table Layout. From the way you're describing your problem, Table Layout seems to be an apt solution. You can even design your layout with Relative Layout as the base. However, you might have to use attributes such as android:layout_alignParentLeft="true", android:layout_alignParentRight="true" and others.

Related

Xamarin Android Screen with Stacked Tables of Data

I need to fit several tables of data on a screen. For small screens, I though the best way to handle this, as a simple solution, was to have them all stacked up on top of one another. And then just to scroll down an view each table as you go down.
The tables of data need to be created with some kind of repeating, data-bound control. It seems like the ListView is the one to use with Android (but I'm open to suggestions).
The thing I am bumping up against is that you can't seem to have ListViews inside a ScrollView (note: I want to support KitKat). The rationale being that you can't have a scrollable control inside a scrollable control.
Is there any simple way of doing this? At this stage, I was hoping there'd be a simpler solution than going for the ViewPager swipe right option.
Thanks
Using the ExpandableListView solved my ux dilemma here. Or rather, the MvxExpandableListView.

What is the simplest layout to choose to make book finder app?

I want to make very simple book finder app for a website.
The prototype is this(how i want it to look like):
I have chosen grid layout, but the search field keeps jumping around, i think the problem is the layout(maybe wrong)
Question: what layout do you recommend for this simple app?
GridLayout or TableLayout will work fine, but you can also use a combination of LinearLayout (one vertical and one horizontal).
If your app stays simple, it is easier to use LinearLayout.
I am not sure I answered your question.

How to properly use the Space class in Android?

I have the need to use some Views as sort of place holders, but to not show anything. Its purpose is to make the TextView's that do show content to resize and share the available space horizontally. It is not necessary to go into detail, but what I am wondering is if I can use the Space class to accomplish this? I have seen it used in a GridLayout blog post, but other than that, there really isn't much on its many possible uses. The doc says its a light implementation of a View, which out of anything, would be the best way to accomplish what I need since it wont be too memory intensive. Is it only intended for GridLayout? There really isn't much info on it online so I was hoping someone could shed some light on the matter.
Just to elaborate a little of why I need to use the Space class, I have, say a LinearLayout. In that LinearLayout could be any number of TextViews horizontally. Say I want to resize it horizontally with a layout gravity, but not actually have another View actually show, just used to simulate that the size of the actually TextView with the content resizes correctly.
I appreciate any help!
The Space class was designed to include empty spaces in general purpose layouts and is very lightweight which makes sure that it doesn't add any overheads. Just put it in your layout like you would any other View. It's not specifically designed for any particular container. You can use it with a LinearLayout, a GridLayout, or anything else. Just don't expect it to display anything (not even a background).
if you want to give the space between layout .this is the way to use space. if you remove margin it will not appear.
hope that helps.
<Space
android:layout_width="match_content"
android:layout_height="wrap_content"
android:layout_margin="2sp" />

DISABLE the auto arrange of widgets in eclipse

I'm fairly new to android programming (making the switch from Windows programming to Mobile Platforms.)
Problem: Every time I add, let's say, a text view, I get a green box around it that will put it in a location. When I add multiple text views, I go to place it down under another text view and everything in my app shifts, and moves everything into a stack on the upper left most part of the screen. It seems like every time I move one thing, 5 other things move with it.
Question: Is there a way to disable that function?
Go to your layout, right click it, then click on change layout. I changed it to absolute layout so I can move any or my widgets around the screen as much as I wanted without the movement effecting other widgets. Hope this helps
Android forces you to develop without a pixel-rigid notation. Basicly you have a set of Layout types (Linear, Relative, etc) that stablish a relation between the child's elements.
Therefore, it is important to know those Layouts, how can you connect them and how their childs are arranged.
In eclipse you can add elements but some things eclipse doesn't know how they are related. Eclipse will update the new data, and therefore moving all kind of views out of the way to update into the new hierarquy you defined. Therefore you can't remove "auto-layout". Even if you change to Absolute Layout (like David suggested) you are not removing the "auto-layout" feature. You are simply telling eclipse that you want to arrange your things with absolute positioning. However, absolute positioning is not advisable since you have several devices with different resolutions.
I advice you to read some information about Layouts and then try to use the XML. Don't be afraid. It can become quite easly. Actually, I prefer XML to interface builder in eclipse. After you get some idea how layouts work you can use make a better use of the interface builder.

Which Android control to use?

I'm taking my first steps in Android programming.
My application is to create entries in a database. For this task I have created a new Activity. All is fine - but I don't really like how it looks.
Currently, the emulator shows this:
I'd like to have something similar to the "New Contact" Activity:
Buttons at the bottom of the window, not directly below the other controls (I'll hopefully figure that out myself)
Buttons within a nice "box" like shown in the screenshot (what's the control hosting the buttons here?)
When soft-keyboard is displayed, the buttons should "move up". If there's not enough room, the entire area should be scrollable (I'll try and figure that out myself too)
Sample can be seen here:
Which control hosts the buttons in the above "New contact" screenshot? I'd like to use the same for my buttons.
One way to figure out what an existing activity does is to use hierarchyviewer and examine the activity's contents.
Another way to figure out what a native Android activity does is to look at the source code. In this case, it would appear that the buttons are inside of a horizontal LinearLayout with style="#android:style/ButtonBar" to give the silver sheen. That style, in turn, uses #android:drawable/bottom_bar as its background. That image can be found in your SDK installation -- go to the platform directory of your choice, then data/res/drawable-hdpi and data/res/drawable-mdpi for the two versions.
The contacts layout looks like a ListView sitting on top of some sort of RelativeLayout or LinearLayout housing the buttons. The silver background may simply have been set using android:background on the Layout itself (layouts are views).
I found that the commonsware books are excellent resources for getting started and have good examples for this type of layout.
Hey, this is a little late, and I know you've already got the silver bar you wanted, which is all good, but I've stumbled upon a really good guide on controlling the soft keyboard for best user experience. It covers, among other things, how to make the visible area resize to fit the button bar in the view while typing, which is done by specifying the activity in the manifest file like so:
<activity android:name=".MyActivity" android:windowSoftInputMode="resize" />
I really recommend reading it, it covers a lot more helpful stuff than just that. Hope that helps; I couldn't see that anyone else has answered that particular part of your question.
You can put them in LinearLayout and assign weight of 1 to each of the buttons.
Also if you own dev phone / or want to see UI of the application in emulator - there is a very cool tool call hierarchyviewer
http://developer.android.com/guide/developing/tools/hierarchy-viewer.html
and you can see how UI of app you like has been laydown.

Categories

Resources