I want to display GridView (with text and image) and group of text box below grid view.
Problem is my gridview do not have fixed entries. It is varying between 1 & 10. I want to resize it as per count of items in grid view. How can i do that? Where can i get height of gridview in JAVA code?
Also, i want to display my group of text boxes ALWAYS at bottom of activity. How can i do that?
Thanks,
JC
I want to resize it as per count of items in grid view.
I really don't recommend that.
Also, i want to display my group of text boxes ALWAYS at bottom of activity. How can i do that?
Step #1: Put the GridView and the LinearLayout inside a RelativeLayout
Step #2: Anchor the LinearLayout to the bottom via android:layout_alignParentBottom="true"
Step #3: Anchor the GridView to the top (android:layout_alignParentTop="true") and to the top of the LinearLayout (android:layout_above="...")
This will cause your GridView to expand to fill the space in the RelativeLayout except that which is taken up by the LinearLayout at the bottom. You can size and position the RelativeLayout yourself as you see fit (e.g., set width and height to fill_parent to have it fill the screen).
Related
I want to have this kind of horizontal GridView (like Google Play). How to have 2 and a half visible items ?
Follow these steps:
Put the GridView into a FrameLayout,
set the layout_width of the GridView to wrap_content, and
set the layout_width of the FrameLayout to a value such that the third item in the GridView only appears half.
Hope it help
I user Two way view in [enter link description here][1]
[1]: https://github.com/lucasr/twoway-view to create horizontal Listview in my app, I want create three list horizontal in a screen but when I add one List horizontal, height of it full screen, I can't set wrap_content or set value for height list view. How I do to add three list in a screen? thank you
Just create 1 Linear Layout for each ListView.
But dont set wrap_content for height of ListView. It will appear some error when using.
I am implementing a GridView which contains images.
I want to expand an image to occupy the whole row when it's clicked as shown in the images below.
I also want to show a button when the image is expanded so the user can take an action similar to how the ESPN app does that.
How can I achieve this?
---->
Surround your layout with a relative layout. Create a layout and a button inside it outside grid layout/inside relative layout. Set it's initial visibility to gone and match it's height, width to row you want it to encompass. Then in the onclick of the image set the layouts view to visible and it's button. Perhaps not perfect but it has the added benefit of allowing scrolling of your gridview while showing the big image you want.
I have a listview, the listviews width and height should be set to match parent. So, if the listview is fully stretched and has only 2 items in it, they are at the top of the listview and on the bottom is too much useless space. I want to know, if it is possible to center these 2 items in this listview vertically, if yes, how?
List height depends on the height of the list item, that is populating the list.
If you have only two items in the list why don't you simply use a Linear Layout instead with weightSum?
Anyway, if you want to achieve the result you requested in your question you have to get the display height using method
getResources().getDisplayMetrics().heightPixels in activity context.
After that you need to set the height of the list item to the height you retrieved earlier divided by 2.
And also set gravity to center_vertical for the textviews in the list.
I have an edit text whose height I am setting as wrap_content.
I have some layout below the edit text.
when ever i write data in it and press enter to go to new line because of wrap content the size of edit text increases and its height increases downwards.Also the layout below is pushed down.
I want the layout below not to be pushed down but the edit text should overlap the layout below. Can this be done?
If you want overlapping layouts you need to use something like a RelativeLayout, if you were to only use a LinearLayout all the layouts will be placed in order.
If you use a Relative Layout you could define that all the TextViews start in the top left but the second one could have a margin so it is offset from the top. Then when your top textbox expands it would overlap the other (assuming the first TextView is drawn afterward , to do this list it in the XML after the other)