How to disable a childdivider in an ExpandableListView in Android - java

I'm trying to hide child dividers in my ExpandableListView. I've managed to make the child dividers transparent by adding:
<ExpandableListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:childDivider="#00000000"/>
But it removes the last divider of the current group as well as removing the first divider of the next group. I want to keep the dividers on both sides of each group, and remove the internal dividers between children.
I'd post an image showing what I'm looking for but this is my first post and it wouldn't let me. :)
Any help would be appreciated!

Here's how I fixed it.
In the parent groups, I gave them borders on the top so that there was separation between the previous child groups and the current parent group.

Related

Responsive layout in Android

I want to make a responsive design in Android i.e. I need such a layout in which I will add views programmatically and they will adjust them according to screen size.
For example:
I want to add 10 views in a layout
When I add them if there is place for only three views per line then automatically they get adjust in four rows and three columns i.e
[0,0] [0,1] [0,2]
[1,0] [1,1] [1,2]
[2,0] [2,1] [2,2]
[3,0]
But as in landscape mode, there is more space vertically
[0,0] [0,1] [0,2] [0,3] [0,4]
[1,0] [1,1] [1,2] [1,3] [1,4]
Use flexbox layout
In builde.gradle add
dependencies {
...
compile 'com.google.android:flexbox:0.3.0'
}
and use it in the layout xml. i.e.
<com.google.android.flexbox.FlexboxLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:alignItems="center"
app:alignContent="center"
app:flexDirection="row"
app:flexWrap="wrap">
...
</com.google.android.flexbox.FlexboxLayout>
It seems the Flexbox solution worked for you, however there is another approach that can provide a different avenue for this problem. In case you are not aware, you can actually define different XML layout files with the same name - 1 for portrait mode, and another for landscape mode.
When creating a new layout file, if you right click on the layout directory and select New > Layout resource file you can configure the orientation here. In the Available qualifiers section, scroll down to Orientation and add it to the file. At this point, you will be able to choose the orientation for this layout and, if you name the file the same name as the opposite orientation, your app will automatically inflate the view that is appropriate for the device's current orientation. Android Studio will also understand the different layout orientations you have chosen while in the editor, and the screen you see in the Design tab will be adjusted accordingly i.e. the landscape layout file will have more room vertically to build the UI with.
Note that this adds a level of complexity to the application itself in the sense that the activity lifecycles will need to be accounted for since the views are now being destroyed and re-drawn by the OS in response to when the user switches the orientation of their device.
Hope this helps either in this situation or in some other situation where you want to accomplish different layouts based on device orientation!

Android: ListView with left status line

Need something like this: ListView and Status Line
Please could you suggest the best way to do this?
add for each row - line which be stretched over the whole height (and half for first and the last item), or a separate element?
Or maybe there already some library?
Just make a View as a line.
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#45a"
android:id="#+id/line"/>
and you can animate this view according
Yeah, 3 different layouts would be the best choice, 1° element with the line stretching only in the second half, middle elements with full line stretch (both top and bottom) and the last element with only top line. You need to check the position in which you're inflating the layout, and inflate the correct one of your choice!

how to make a header position fixed while scrolling down

Within a NestedScrollView how do you make every Header stay at a specific point while scrolling down in this case right under the Image until another Header comes by while scrolling down which pushes the first Header and gets replaced by the 2nd Header and so on. I hope the image makes sense to what I am trying to accomplish. Thank You!
If you want to achieve this you should not use NestedScrollView instead use a linear layout with Image at the top then a listview with sticky header. I think this will solve your problem
Here is the link for the list you want. https://github.com/emilsjolander/StickyListHeaders

A way to adapt the position of items in an android layout

I am currently work on an Android project, I have to show several check-box, now they are in a Relative Layout and all are positioned to their left neighbor.
So in landscape, I have a line of check-box, the problem is if I switch in Portrait the line is cut, because there are too many elements. So is there a simple way too automatically go to the next line when the element will be cut ?
I can change the layout type (relative, linear, ...).
U may check this library flowlayout coz u cant easily achieve this behavior.

ExpandableListViewGroupPosition?

I have implemented ExpandedListView. I have 2 questions for that
When I expand and scroll child item ,the group header also scroll ,is any way to keep that group header at top always even we scrolling child item list ?
Is any way to fit ExpandableListView (before child items comes) to phone screen , right now in bottom lot of blank space ?
For your first question:
no there is no why that you can fix the group view, if you want to fix group i would suggest you to make four list view on screen. where in a Linearlayout make 4 textview and 4 listview placed alternately so that they are fixed and if there is no child inside you can write some appropriate message saying there is nothing to display.
And i guess it solve your second question as well ?
1. When I expand and scroll child item ,the group header also scroll ,is any way to keep that group header at top always even we scrolling child item list ?
No, ExpandableListView's Header's (Parent) and Childs are connected to eachother You can not independently scroll the Child views besides scrolling parent views.
2. Is any way to fit ExpandableListView (before child items comes) to phone screen , right now in bottom lot of blank space ?
You can fit the ExpandableListView by setting its height and width to fixed but it will be always affected as and when you will add some data into it. Till then you can not fit it into the screen.

Categories

Resources