If i have a expandablelistview with custom layout (group.xml and child.xml), the are any way to set a 9.png background for all the row(group + child? if is expand, only row if collapse).
For example i have 4 groups
1row collapsed with background
2row collapsed with backgound
3row expand
group <---- I want to use 1 background for group.xml and child.xml, this is it, the group background expands to be background for child too
child
5row collapsed with backgruond
Or, when i use expandablelistview, and define a row.xml background, when i expand a groupo, the background envolpes too to the child?
I am afraid this is not possible. Since you are referring to two different resource files in a ExpandableList, you can't group them as a single view. Being this the case, you can set the 9 patch to your total expandable listview which you might not want as your need. So here goes the round about method.
1)You can have three set of images. Once full closed image. second image can look like the top half of the first image and third image to look like the bottom half of the first image.
2)Add the listener on GroupExapnded() to your ExpandableListView. Now this will return you the position of the view, boolean flag of the view state(whether it is expanded or collapsed) and and the object to that view.
3)Now based on the boolean flag you have to play around with the images as of which image is to be as the background.
There will be two scenarios,
1)For the expanded state, you have to apply the second image to the group and the third image to the child.
2)If the group is collapsed , you have to apply the first image as the background to the Group View.
This is the most ugliest way which I know by myself. if you can get any better solution kindly inform me to.
Related
I currently have an activity with a horizontal scrollview, and inside it I have an add button (ImageView) to let the user add some images to the same horizontal scrollview after clicking it. How can I display a group of images from app resources (such as drawable) as a sort of "pop up" to let the user pick one, without changing the current activity?
You need to create recyclerView with horizontal layout. The adapter of the recyclerView will have the functionality to implement a button click. The onClick of the button will add items to the adapter. These items may contain your required images.On every button click you need to call notifyDataSetChanged.
This can be solved by inflating a custom xml layout (containing a GridView) on an AlertDialog. To display the images on the GridView you need to create and set a custom adapter to it. The adapter shall have a function getView(), which will return each of the Views to be shown on Grid cells. You can also use Picasso Library to load the images.
Here is a brief tutorial
http://www.101apps.co.za/articles/gridview-tutorial-using-the-picasso-library.html
Hint: Remember to define the number of columns of the grid, and calculate the size of each image based on the screen size. This way you can fit the amount you like on each row. You can do this for both portrait and landscape orientations by overriding the function onConfigurationChanged.
Hint 2: Remember a GridView already has the scroll property, which needs to be activated (android:scrollbars="horizontal"). Using a ScrollView as parent of a GridView will cause it to wrap the image, even with MATCH_PARENT property activated, causing layout problems.
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.
Sory I can't describe a right title for my question,
I want to create listview something like this
In top of list view on screen look like
and when user scroll the list in screen will be like this
and in end of list is
I have 3 picture for top list, middle and bottom list.
I already try to add header and footer for top image and bottom image but looks like the picture is inside the list view
I try to create vertical linear layout and put picture top,middle and bottom in sequence but still not get result that i expected
Do anyone have a suggestion for listview like this
Don't set your frame background for entire listview or its parent. Instead first slice your frame background into three parts, (i) topframe (ii) middleframe (iii) bottomframe. Now create a custom listview and set background for each and every list rows.
In order to achieve your design, you need to find the first and last item of list and set topframe for first row and bottomframe for last row , all the other rows background should be middleframe.
I currently have a very plain ListView with no background image and just text for each item in the list.
Some people have voiced the problem that it isn't intuitive to click on the list items.
So I am researching what kind of a background image to create so that it makes the list item look "very clickable"
One option is to have the background image contain those little icons on the right that look have something like a ">" and its a sign that it should be clicked on.
But I am wondering what if the text is long on the listitem and it will overlap over the ">" icon. How is that usually handled? Is there a way to make text only extend 90% of the entire listitem?
Thanks!
The easiest and cleanest solution would be to make your TextView width match_parent and use the android:drawableRight attribute in your XML to specify the drawable that you want to be displayed on the right side of your text.
If you want to do something like every item on list should be shown clickable, just do one thing, design a layout with text view and inflate that layout in your lsitview adapter class in getview method. and instead of return convertview, return your inflated view from there.
I've got listview that in a row it contain 3elements: imageview, textvie and another imageview. I've set my listview to setItemsCanFocus(true) and every item is set setFocusable(false). Screen:
http://img252.imageshack.us/img252/4042/zrzutekranue.png
I can navigate on the screen (click on text/image, I have those fields set to clickable and focusable), but there is no visible focus. I'd like to have the default focus style, when background changes.
I can add sth like:
setBackgroundColor(xxx)
but I'd like to have that fancy background that is lighter in the middle and darker at the ends.
The upper row on the pic is what I've got, and lower is the ideal focus notification, of course it should be narrow so it would only be background of the text view.
Sorry for my English.
PS I also used for textview
android:layout_height="fill_parent"
to fill for height which isn't the best piece of coding.
In the List View, all the list items are in different views. In your case the Image View, Text View And Image View lies within a single View. So according to me you cannot have focus on the items within a single View in a list View.