I have a very simple listview, but now it shoes all empty when open it, I wanna user see the light grey lines in this empty list view to let them know this is something will list, Is there any way to show the lines when the listview still empty please?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.anna.DiscoverActivity">
<android.support.v7.widget.SearchView
android:id="#+id/searchview"
app:queryHint="Search HoodMark"
android:background="#color/colorAccent"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<ListView
android:layout_below="#id/searchview"
android:id="#+id/discover_list"
android:divider="#color/colorAccent"
android:dividerHeight="4px"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</ListView>
</RelativeLayout>`
Yes there is. Create an emptyView, design it as you like then supply it to the your adapter. Like this:
//inflate your empty view
View emptyView=getLayoutInflater().inflate(R.layout.emptyViewLayout,null,false);
//set to your listView
listView.setEmptyView(emptyView);
Related
I used SwipeMenuListView from github It works but Views are not consistent as in the picture
Activity layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.robo.lolita.swipemenurecyclerview.MainActivity">
<com.baoyz.swipemenulistview.SwipeMenuListView
android:id="#+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
this is simple layout swipe menu layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent" android:background="#android:color/holo_blue_bright">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/count"/>
</LinearLayout>
SwipeMenuCreator creator = new SwipeMenuCreator() {
public void create(SwipeMenu menu) {
SwipeMenuItem deleteItem = new SwipeMenuItem(
getApplicationContext());
deleteItem.setBackground(new ColorDrawable(Color.rgb(0xF9,
0x3F, 0x25)));
deleteItem.setWidth(dp2px(90));
deleteItem.setIcon(R.drawable.camera_icn);
menu.addMenuItem(deleteItem);
I need to attach delete button to the item of listview on Swipe. this swipe menu with delete button. i want to delete the item on clicking the delete button but views are inconsistent in swipemenulistview. Any help to acheive this. Well i cannot do swipe to dismiss and i know we should not mimic the UI of other platforms. but this is the requirement .
I'm trying to make simple GridLayout with 3 columns but although I get 3 columns I get strange gap between rows. So, I get 3 images in row than one row that is empty (which it seems has height matching height of the row abov(that has images), then row of 3 images, than strange gap...etc. I expected not to get than blank gap. How to remove this blank gap? Trying to set wrap_content to layout_height on recycler view, and fragment didn't helped.
This is my code:
final GridLayoutManager layoutManager = new GridLayoutManager(this,3);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(adapter);
This is xml of the activity:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
tools:context="com.adriagate.adriagateonlineandroid.activities.ImagesActivity">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:id="#+id/fragmentImagesHeader"
android:name="com.adriagate.adriagateonlineandroid.fragments.ImagesHeader"
tools:layout="#layout/fragment_images_header" android:layout_width="match_parent"
android:layout_height="match_parent" >
</fragment>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:id="#+id/fragmentImagesGrid"
android:name="com.adriagate.adriagateonlineandroid.fragments.ImagesList"
tools:layout="#layout/fragment_images_list" android:layout_width="match_parent"
android:layout_height="wrap_content" >
</fragment>
</RelativeLayout>
Notice that this layout has an important fragment called fragmentImagesGrid which has this layout:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.adriagate.adriagateonlineandroid.fragments.ImagesList">
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view_images"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:listitem="#layout/recycler_view_images_one_row"
>
</FrameLayout>
This i the layout of the one element inside recycler view:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
>
<ImageView
android:id="#+id/imageViewImagesAllOneRow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
tools:src="#drawable/slika_200_200"
/>
</FrameLayout>
Looks like it happens because your images have different sizes.
Change your item to LinearLayout and set its layout height and width to match_parent. Set gravity="center" (Of the linear layout).
Another issue is android:layout_height="wrap_content". The RecyclerView doesn't work well when you set the height property to wrap_content. If you still want to use RecyclerView with wrap_content, you can ckeck this solution
I'm thinking of making an app's first view like this: it's just a basic search view with one EditText and two Button on it. I want the background image zooming in and out when user stay on this view, typing or doing nothing.
So I add zoomin.xml and set the animation to the view. Zooming is working but only problem is that it's zooming everything. I know it's because I set background image in the root element of the xml, but I don't know how to make it ONLY zoom in the background picture without affecting other views.
Here's my background image code in root element.
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
tools:context=".MainActivity"
android:background="#drawable/bcg2"
android:orientation="vertical"
android:gravity="center">
So I'm thinking if any floating view will do this? But I don't know how to do it. Or any other suggestion?
Thanks!
Use a fullscrean ImageView instead of the background attribute of the Linearlayout and zoom only the image
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/image_to_zoom"
android:src="#drawable/bcg2"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
tools:context=".MainActivity"
android:orientation="vertical"
android:gravity="center"/>
</RelativeLayout>
I have 2 files in the res.
Activity_main.xml is
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.test2.MainActivity"
tools:ignore="MergeRootFrame" />
fragment_main.xml is
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.test2.MainActivity$PlaceholderFragment" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world" />
</RelativeLayout>
I plan to change the layout where I problem in this current layout when I drag and drop all item just overlap on each other how to make a nice form type layout? What adjustment and which file must I adjust?
It sounds like you are using the Eclipse GUI tools to create your layout. I strongly suggest that you read about Android Layouts. If you want, you can edit the XML layout text directly or at the very least this will help you understand the properties you can set for your controls to get the exact look that you want.
I have an application in which I am using a list view
setListAdapter(new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_activated_1,titles));
now what I get is like this
as you can see when I press on the text it senses it and not anywhere on the row beyond that.Is there any way I can work this thing out other than using my custom xml file(resource) for list.
Xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MovieCritics" >
<fragment class="com.example.moviecritics.FragmentMovieName"
android:id="#+id/movie_name"
android:name="android.support.v4.app.ListFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
and it's working fine in landscape mode
Try android:listSelector in your ListView