i want to know if there is any way to display a drawable file in between the grid view rows ?(only rows) I want to get the layout in the following way
i used grid view to display books and i have divider in drawable folder and i need to show it in the that way
i searched a lot but every thing just says how to give color divider between rows but i need to display the divider from drawable
is there any way to do it?
You can define custom divider, check code snippet below:
<GridView android:layout_width="wrap_content"
android:divider="#drawable/divider"
android:dividerHeight="3sp"
android:layout_height="wrap_content" />
where divider is your custom drawable image. You can also check this link for more clarification:
custom divider
Related
I want to customize my listview to achieve this design,are there any library available for this?what can be best way to achieve this.Are there any disadvantage with such designs.
Thanks,
You can achieve this in two different ways
add an image instead of divider containing these tilt lines you can do this by using a simple line of code in your layout or in your class
android:divider="#drawable/divider_image"
or you can change it in you java class like this
list.setDivider(R.drawable.divider_image);
the second way of achieving this is you set a static image in you item layout below the item and change it according to your need as if the item is odd set a different image and if the item is even set a different image
<ImageView
android:id="#+id/imageViewDivider"
android:src="#drawable/divider_image"
android:scaleType="fitXY" />
and change the image in java class
ImageView imageView = (ImageView) findViewById(R.id.imageViewDivider);
imageView.setImageResource(R.drawable.divider_image);
I am working on a POS system which needs a delivery screen in which, I have to show all orders in number of columns of list in Cardview.
Something like shown in this image:
I am using cardslib to get the cardsview in my app. Can you please help me to implement this type of layout with cardslib. Or Can you suggest me what will I have to do to have this kinda layout in my app??
I also tried twowayview but couldn't get the idea for breaking the card in multiple columns just like the yellow card shown in above image. Please help me..
Finally, I found a workaround for this query. I found a twoway- gridview lib which did help me to add data vertically and scroll horizontally. I used this library by keeping number of rows and columns constants according to screen size and referred them in gridView. Following code is the one which is used from the above library.
<com.jess.ui.TwoWayGridView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/horz_gridview"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#FFC4C4C4"
app:cacheColorHint="#E8E8E8"
app:verticalSpacing="-4dp"
app:horizontalSpacing="0dp"
app:stretchMode="none"
app:scrollDirectionPortrait="horizontal"
app:scrollDirectionLandscape="horizontal"
app:gravity="center"
android:layout_gravity="center"/>
Then, Just make a layout to fill each cell of gridView with. You have to create an adapter to fill each cell of the grid with respective content.
I just assumed that each cell of grid will have single line of the view. No multiple lines in a single cell. To show start and end of a card, You can use different background colors to the starting and ending cells.
In short: You have to make a List of data which u have to put it in grid with the help of adapter.
You can refer this tutorial to use above library.
I have an expandable list view I am using in one xml file which has a background. Upon loading, it looks fine, but sometimes while browsing the background of each list element shows infront of the background of the base view.
The list elements are defined in their own xml file.
Can I make the list elements backgrounds become transparent somehow, so that the background of the baseview is shown all the time instead, even when expanding/collapsing the view?
The answer can be found here :)
http://developer.android.com/resources/articles/listview-backgrounds.html
Use
android:cacheColorHint="#00000000"
On your list
Set this all four properties for expandablelistview. It worked for me....
android:childDivider="#android:color/transparent"
android:listSelector="#android:color/transparent"
android:cacheColorHint="#android:color/transparent"
android:background="#android:color/transparent"
Or programmatically set expandablelistview transperent:
ExpListview SecondLevelexplv = new ExpListview(mContext);
SecondLevelexplv.setBackgroundColor(Color.TRANSPARENT);
SecondLevelexplv.setCacheColorHint(Color.TRANSPARENT);
SecondLevelexplv.setDivider(new ColorDrawable(Color.TRANSPARENT));
SecondLevelexplv.setSelector(android.R.color.transparent);
I have a list view which has a footer.
It displays numbers and at the bottom is the total.
I want to be able to show the rows without a divider between them. OTOH I DO want a divider before the summary row.
Is there any easy way to do this?
You can set android:dividerHeight to 0 in your list.
Then use custom layout for footer in which you add divider by yourself. For example, that can be a TextView with no text, android:layout_height set to 2 and android:background set to some color.
When you have custom layout for the footer, just add divider on top of it. It can be for example View of hight 2dp and different background color.
I had to do this programatically, since setting android:dividerHeight="0dip" in the XML didn't work for me:
getListView().setDividerHeight(0);
i have a listview with a bunch of items in it, each item has its own background, the problem is that if i only have one item in a list, the rest of the "empty" slots of the list is black. I tried applying a background around the listview and also on the view that sorrounds it (relativeView) and i get a strange margin around the whole list like the picture at the bottom. The question i have is, how can i remove the actual "borders" around the list so it still fills upp its parent ? .
Remove any padding you may have used in your XML layout file.
Try putting in the following code in the listview's layout:
android:cacheColorHint="#00000000"
Change your listview height like this android:layout_height="fill_parent"
use android:fadingEdge="none" in listview in layout