I want to create a screen that has a column of scrollable images on the left and a similar column on the right with space in between them. The user selects an image in the left column and based on that selection, the images in the right column get filled up. I can drag images from the right column into the space in between to create a composite image.
What kind of layout should I use to accomplish this? Is this one view or three views? Is this a Vertical Linear Layout with three columns and do I need to use Grid view in the left and right columns?
Thanks!
IMHO, the left-hand list of views is a ListView. The right-hand list of views is a ListView. The middle...I have no idea, since I do not know what you mean by "create a composite image". It might be a ListView, it might be a vertical LinearLayout, it might be something else.
The three columns (ListView, thingy, ListView) are probably formed via a horizontal LinearLayout or a RelativeLayout.
Related
I am building an app where I want a message to be displayed at the bottom and top of the List like this example. Ive tried to nest the ListView inside a column, but that is giving me an error. Please Help
Use a column with 3 children. Put an expanded in the middle one and put your ListView in that.
The expanded will take up any room that is not not taken up by the top and bottom children of the column, ensuring that your ListView adapts to whatever you put around it but it always takes up every pixel that you didn't already need for the top and bottom children.
I have a listview with rows as big as the device screen and I want to show row per row while sliding, I don't want to show parts of rows when doing so, is there any way of doing it.
ListViews are not made for this kind of use case. ViewPagers are, but they scroll horizontally. It's possible to make it scroll vertically (see Android: Vertical ViewPager), which should be what you're looking for.
The problem with adjusting the size of each ListView item to fill the screen is that match_parent simply doesn't work. You would need to calculate the exact size you need (screen height minus action bar and other views that are not part of the ListView). It's probably possible, but not worth the trouble.
I need to do an activity with two "parts". The first one, uses the top half of the screen, and there, I will show some fields (name, date,...). The second one, uses the bottom half of the same screen, and there, I will show a table, with three columns, and with some rows. The quantity of rows is undefined, because they come from a web service.
My doubt is how to do this second part, with a vertical scrollbar table, where the user will see the first half static, and could be able to roler the bottom half to see all rows of the table (like an iframe). I need to use table, because my cells need to be aligned.
I have already tried tablelayout, listview, gridview, and I can't find a way to show the vertical scrollbar.
You could use a ScrollView.
Note though that ScrollView supports one direct child so you may wrap everything up.
You can use something like the following:
MainLayout
TopHalfElements
ScrollView
Linear/relative/frame/whatever layout
Rows From Webservice etc.
You need to have a main layout inside the ScrollView as it only supports one direct child.
I would like to build an heterogeneous grid widget in Android like the one is used in apps like Google+ for tablets or Pinterest. I cannot find any tutorial and it seems particularly difficult.
Unfortunately GridView can have only cells of same size while I want to achieve different sizes cells. Can you point me to any good tutorial? I only know that I have to extend AbsListView.
Depending on how variable the items' heights are, you have a few options:
If you're looking to do a GridView with many variations of heights (e.g. Pinterest) you should play around with StaggeredGridView - as far as I can tell, it's the best open source solution out there right now.
In the image you posted, it looks as if there are parent rows with variable height children - this is a slightly easier problem to solve, and can be mimicked by using a regular ol' ListView and a subclass of BaseAdapter. Writing out the code for this is too involved for a SO answer, but i'll give you an overview of how I might achieve this effect.
The BaseAdapter must determine the rough layout of each row ahead of time such that it can report to the listview how many rows it will require - you'll need to override getCount().
In getView() of your adapter, you will inflate a single LinearLayout (or perhaps use convertView if it's been recycled) and add as many children (again, more LinearLayouts) as you will require for the width of the device (you should figure this out at runtime, unless you want to just create a phone and tablet version).
Each child LinearLayout added to the row should be set to weight=1 such that they stretch to the entire width of the parent row. In the screenshot you posted, there are 3 columns (the third id cut off).
Each child LinearLayout you just added to the row represents a column. You should set their orientations to vertical, being as they are columns!
Within each column, if you were to add a single child, you'd have a gridview.
If you wish to achieve the effect above, you can add more items to each column.
For example, row 1, column 1 has one large child. Columns 2 and 3 in row 1 both have 2 half-height children.
i'm trying to layout a fairly basic screen. it's just a details view screen after a list item click.
initially i'm looking to acheive a side by side stacked label value type of screen.
for example, where to the left of colon is static text and to the right of colon being dynamic values based on row clicked.
first name: john
last name: doe
last login date: yesterday
additional info: blah
i've started with a relative layout with a bunch of text views in it all positioned accordingly to acheive something like what i was looking for.
The problem arises when the dynamic data being displayed grows and stretches its enclosing text view. Of course the static labels don't grow and everything gets mis aligned...
I'm wondering if there is a different way of tackling this sort of layout...
i was shying away from stacking a bunch of horizontal linear layouts inside a vertical linear layout.
is table layout the way to go? i've read that "they usually aren’t the best tool for doing so, as they are derived from LinearLayout and not the most efficient of layout controls".
Yes there is. Use a listview with a layout predefined in xml. Use a simplelistadapter and pass it the dataset that you want to populate it with.
Edit
Here is a great tutorial:
http://www.vogella.com/articles/AndroidListView/article.html
For a simple form like you want to create I'd suggest using a TableLayout. It is simple to use. As you said the alternative to a TableLayout would be horizontal LinearLayouts in a parent vertical LinearLayout. Using a TableLayout will also automatically align the right side dynamic content for you. Everything on the right side will be treated as a column so if one resizes, they all resize to match.
In your particular scenario I would believe that the TableLayout would work well (although I have also heard similar issues of efficiency/performance). As long as the entire Viewgroup of this Activity isn't complex, I don't think the performance will be too noticeable.
If you are attempting to make the RelativeLayout version work, perhaps you can try this: Have all of your static labels are aligned to the left using android:layout_alignParentLeft and have each aligned to the top of the dynamic TextView they are corresponding to using android:layout_alignTop. This should keep the static TextViews aligned to the left while aligned to the dynamic view relative to it.
Now that those views are aligned, we can horizontally align the dynamic views to the longest static TextView using android:layout_toRightOf. From there, all the remaining dynamic views can also android:layout_alignLeft to this anchor dynamic TextView, or also align to the longest static TextView in the same manner that the anchor was. This solves the horizontal alignment of all the dynamic TextViews.
Finally, we can set that each dynamic TextView falls under the next, since the dynamic TextViews are our determining our vertical location within this RelativeLayout. Each view can use android:layout_alignBelow to chain the fields to align vertically.
I believe this should work for you and I can edit this post later in the day if you would like a sample of code.