Is it possible to make a space between horizontal Listview items?
I try this for listview.
android:divider="#ffff00" android:dividerHeight="10dp"
It's working fine in listview. but I want add divider between horizontal Listview items. How to rectify this Problem?. Share Your Idea?
Set border around your list items in xml file or add custom view as below:
<View
android:layout_height="match_parent"
android:width="1dp"
android:background="#ffff00"
/>
what do you mean by horizontal list view in Android?
If it is customised list then add a view betwwen two items and set the backgroundcolor for the view.
With all respect to #Mihir Shah, updating his answer to match your requirement.
Set border around your list items in xml file or add custom view as below:
<View
android:layout_height="match_parent"
android:width="1dp"
android:background="#android:color/transparent"
/>
This will provide space you require.
Related
Inside my recycler view item layout I want to add something like horizontal recyclerview layout, because I don't know how many ImageViews I need, that's why I can't create them as a static layout. The number of icons depends on server logic. How can achieve something like the picutre below ?
Thank you in advance!
You Need Add Horizontal Recyclerview Inside The Main Recyclerview.
Your First RecyclerView is Verticle list and inside every index create another RecyclerView It's a Horizontal. so you can display n number of Imageview.
You have to create Recyclerview inside the child layout of your main Recyclerview
Something like
Suppose this is the Main Recyclerview
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/mainRecyclerview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:listitem="#layout/item_demo" />
In your child layout, Let's say item_demo you have to add another Recyclerview for the imageView that you want to show in horizontal
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/mainRecyclerview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
tools:listitem="#layout/item_child" />
item_child layout contains the Imageview that will display horizontally
How to show only a left colored border on each ListView row?
I have a 5 degree termometer for user reputation and I want to show the respective colors at the left border of each listview row.
Like this link
Thanks guys!!
The easiest way would be to create a dummy View in your item layout. That way you can easily change the color of the background when you bind the layout to the data. Something like this:
item_list_layout.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android">
<View
android:id="#+id/termometherIndicator"
android:height="match_parent" android:width="4dp"
android:background="#color/default_color" />
<LinearLayout ....>
<!-- The rest of the item layout goes here -->
</LinearLayout>
</LinearLayout>
Then get the view reference in code behind using the Id and change the background color to whatever you need.
The ListView row should be an horizontal LinearLayout, and include this at the beginning, as a first child, followed by the TextView:
<View
android:id="#+id/reputationColor"
android:layout_width="4dp" //Aproximately the size from your image
android:layout_height="36dp" //About the size of a List Row, but less, as seen in your image
android:layout_gravity="top"
/>
You will need a CustomAdapter for your ListView, which you can find a full example in here
Inside the CustomAdapter, you can set the colour programatically with
View reputationColor = (View)findViewById(R.id.reputationColor);
switch (reputation) {
case 1:
reputationColor.setBackgroundColor(#ff0000);
break; //Include other cases up to 5
default:
break;
}
For more information on CustomAdapters, go to the following websites:
ONE
TWO
THREE
You can add a panel to the leftmost part of your app. In that panel you can place one of the predefined images of thermometer. You only have 5 levels, right? Once value changes - select corresponding image of thermometer reading and redraw gui element.
I have a RecyclerView and inside it I want to put CardViews. Now I want these CardViews to overlap themselves like inside a Stackview, but i cannot find a solution to let my view look like this.
The result should look like the reminder app from iOS (see the screenshot) or like a deck of cards. The user should be able to scroll through the cardviews and drag them on the position he wants them to have.
Does anyone have an idea how to solve this problem? Or is there any library that could help me to let my view look like this? I have already tried an custom ItemDecoration but only the visible items of the RecyclerView are shifted and so the RecyclerView has a wrong behavior on scrolling.
You can achieve overlapping of items by using negative bottom margins for your item layout. See the documentations for details.
For example:
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="-10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test"/>
</android.support.v7.widget.CardView>
I want to create a ListView and a few other text boxes for filtering the list.
Is there a way to make it happen using one activity (i.e at the same page)?
One more question:
May I modify a ListView directly without creating a ListActivity? and how do I make the ListView in my ListActivity visible? (how do I link it with the xml?).
Yes. ListActivity seems to cause a lot of confusion for people, when all it is, is a regular activity with a ListView as the content, some helper methods, and that's it.
To add your own, create a new layout file and add all the widgets you need like you would any other layout file. Example:
<LinearLayout xmlns:android="http://schemas.android.com/res/apk/android"
android:weightSum="1.0"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/whatever"
android:layout_weight="0" />
<ListView
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1" />
</LinearLayout>
You certainly can create a layout which contains both a ListView and other controls! Make your Activity have a layout which contains both your ListView and your other controls.
<RelativeLayout>
<ListView android:id="#+id/listy"/>
<Button android:id="#+id/buttony"
android:layout_below="#id/listy"/>
</RelativeLayout>
In your Activity, you'll still need to hook up your data adapter to the ListView and so forth.
Yes, you can have ListView together with some other required views with in the same Activity. The way I would do this is to define an Activity and add ListView (with width and height set to fill_parent) and add a SlidingDrawer which contains all the options required to alter ListView. With this approach, your ListView will take up all the space on screen and offering user to interact freely. However, on the other hand, SlidingDrawer will give give extra space for all the list altering views/options.
In one of my activities I am showing certain information and at the end I have a ListView.
So my layout looks a bit like:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="30dip"
>
...
<ListView android:id="#android:id/android:list" android:layout_width="wrap_content"
android:layout_height="fill_parent" />
</LinearLayout>
When I run the application in the emulator I see that the information before the list view is always shown in the screen and there is a vertical scroll for the ListView only.
Is there a way to change this scrolling behaviour ?. What I would like to have is a vertical scroll for all the information in the screen, not only at the level of the ListView.
I tried wrapping the LinearLayout with a ScrollView, with different combinations of the android:layout_height attribute for all the views involved but I did not get the effect that I was looking for. Besides, some people say that it is a pretty bad idea to wrap a ListView with a ScrollView :
Android ScrollView layout problem
Scrolling with Multiple ListViews for Android
Thanks for any other ideas.
I've not tried this, but you might want to look at you tube video:
Google I/O 2010 - The world of ListView
http://www.youtube.com/watch?v=wDBM6wVEO70
Starting at time 27:11, it talks about how to make info above and/or below a ListView scroll with the ListView. It refers to scrolling headers and footers, but it does say you can put anything you want in them.