ListView not scrolling.Just Listview - android

I have tried a lot of things but still not scrolling i added scrollbars even though it was not related. i tried to change focus but still no scrolling.
Here is my code for Contacts_list.xml
<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
tools:context="Contacts_fragment"
tools:listitem="#layout/fragment_contacts"
android:scrollbars="vertical"
/>
and code for fragment_contacts.xml which is included in above xml.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal"
android:weightSum="1"
android:gravity="bottom">
<ImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:id="#+id/image"
android:contentDescription="#string/Description"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/phone"
android:textSize="14sp"
android:gravity="bottom"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/image"
android:layout_toEndOf="#+id/image" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="#+id/name"
android:textSize="16sp"
android:textStyle="bold"
android:gravity="top"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/image"
android:layout_toEndOf="#+id/image" />
</RelativeLayout>
This is my complet Code

Use Layout like below xml in Contacts_list.xml and no need to include scroll bar.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="#+id/list"
android:layout_height="wrap_content"
android:layout_width="match_parent">
</ListView>
<LinearLayout>

Try this xml for listview
<ListView
android:id="#+id/sampleListView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
tools:listitem="#layout/fragment_contacts"
>
</ListView>

Related

How to make Android ExpandableListView not scrollable?

I can't figure it out how to make ExpandableListView not scrollable, always at full size and positioning at the bottom of the layout, but also maintain the ability to scroll the textView if it goes out of bounds. I know it is not recommended to have ListView in ScrollView. But how to achieve this? Now everything looks like this:
The layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="#mipmap/ic_launcher"
android:id="#+id/imageView2" />
<TextView
android:text="Order description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/imageView2"
android:id="#+id/orderDescr"
android:paddingTop="5dp" />
</RelativeLayout>
</ScrollView>
<TextView
android:text="label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textView5"
android:paddingTop="15dp"
android:paddingLeft="16dp"
android:paddingRight="16dp" />
<ExpandableListView
android:id="#+id/expandableListView"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:indicatorLeft="?
android:attr/expandableListPreferredItemIndicatorLeft"
android:childDivider="#00000000"
android:layout_below="#+id/orderDescr"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="5dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:headerDividersEnabled="false"
android:footerDividersEnabled="false"
android:isScrollContainer="false" />
</LinearLayout>

Items of nested Linear Layout not clicked

I have an MvxListView which contains items which are based on MvxLinearLayouts. The goal is to get a grouped list. This works so far.
The issue I have, is that the click event is now catched by the linear Layout and not the item I click on. I tried to make the ListView and the LinearLayout above not clickable but that didn't work.
Here is my code:
MvxListView:
<MvxListView
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/payment_List"
android:descendantFocusability="afterDescendants"
android:listSelector="#drawable/list_item_selector"
local:MvxItemTemplate="#layout/listitem_payment_grouped"
local:MvxBind="ItemsSource Source" />
listitem_payment_grouped:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:descendantFocusability="afterDescendants"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/black"
local:MvxBind="Text Key" />
<Mvx.MvxLinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/payment_List"
android:listSelector="#drawable/list_item_selector"
local:MvxItemTemplate="#layout/listitem_payment"
local:MvxBind="ItemsSource .;ItemClick EditCommand" />
</LinearLayout>
listitem_payment:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/light_gray"
android:paddingLeft="6dp"
android:paddingRight="6dp"
android:layout_marginBottom="4dp"
android:translationZ="3dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/black"
local:MvxBind="Text Date, Converter=DateTimeFormat" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/black"
local:MvxBind="Text PaymentAmount(., ChargedAccount)" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_marginTop="5dp"
android:layout_weight="0.9"
local:MvxBind="Text Category.Name" />
<ImageView
android:src="#drawable/ic_done_black"
android:layout_gravity="right"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_weight="0.05"
local:MvxBind="Visible IsCleared" />
<ImageView
android:src="#drawable/ic_recurring"
android:layout_gravity="right"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_weight="0.05"
local:MvxBind="Visible IsRecurring" />
</LinearLayout>
</LinearLayout>
If so then you have to indicate that the views created by the ListAdapter contains focusable items by explicitly adding setItemsCanFocus(true) in your listView,
myListView.setItemsCanFocus(true);

Item to right Side?

I am trying to keep all item to right side I find code in Google but it is not working with me.
latest_lsv_item.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.apps.newsapplication"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/list_bg"
android:orientation="horizontal" >
<com.example.util.RoundedImageView
android:id="#+id/img_newslistlatest"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center"
android:layout_margin="13dp"
android:scaleType="centerCrop"
app:border_color="#color/divider"
app:border_width="8dip"
app:round_background="true" />
<TextView
android:id="#+id/txt_newslistheadinglatest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="0dp"
android:maxLines="3"
android:text=""
android:textSize="18sp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/text_color" />
</LinearLayout>
fragment_lastest.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:background="#color/background_color"
android:gravity="center"
android:id="#+id/rootlayout"
android:orientation="vertical" >
<ListView
android:id="#+id/lsv_latest"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:cacheColorHint="#00000000"
android:divider="#color/divider"
android:dividerHeight="1dp">
</ListView>
</LinearLayout>
if you want more code or file I will past it here...
activity_main.xml
LastFragment.java
etc...
I try to use RTL but also not working with me

Button is not displaying in layout in Android

I have made an Android activity. In this activity I have a ListView and a Button. I want to add the Button to the bottom of screen. I have tried so long but it's hidden from tabbar. My xml code is as below. Please help me.
code
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<com.eps.blancatours.uc.Header
android:id="#+id/hdr_dest_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" />
<RelativeLayout
android:id="#+id/rl_main_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/hdr_dest_list"
android:padding="10dp" >
<ListView
android:id="#+id/dest_List"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="#+id/btn_next" />
<Button
android:id="#+id/btn_next"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="40dp"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:background="#D41016"
android:text="#string/next"
android:textColor="#ffffff"
android:textSize="14dp" />
</RelativeLayout>
</RelativeLayout>
Make changes like below -
<?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"
tools:context=".MainActivity" >
<LinearLayout android:id="#+id/li"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<com.eps.blancatours.uc.Header
android:id="#+id/hdr_dest_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/button1"
android:id="#+id/list"
android:padding="30dp"
/>
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="#68bdb6"
android:text="#string/Select" />
</RelativeLayout>
You did not close your main Relativelayout just close that layout button will appear below the listview
You didn't close your main RelativeLayout with </RelativeLayout>.
For me your code works, you just have to close your relative layout.
It does working here, all I added is just </RelativeLayout> tag before the parent tag.
and my text in place of the #String reference.
also Try changing android version when rendering layout.
Wrapping ListView and Button with nested RelativeLayout is redundant. You could set you XML like this:
<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" >
<com.eps.blancatours.uc.Header
android:id="#+id/hdr_dest_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" />
<ListView
android:id="#+id/dest_List"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:padding="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/hdr_dest_list"
android:layout_above="#+id/btn_next" />
<Button
android:id="#+id/btn_next"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="40dp"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingBottom="10dp"
android:background="#D41016"
android:text="#string/next"
android:textColor="#ffffff"
android:textSize="14dp" />
</RelativeLayout>
Also use match_parent instead fill_parent
Add the below inside Button
android:layout_below="#id/list"
Add android:orientation="vertical" on your both RelativeLayouts as
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<com.eps.blancatours.uc.Header
android:id="#+id/hdr_dest_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" />
<RelativeLayout
android:id="#+id/rl_main_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/hdr_dest_list"
android:padding="10dp"
android:orientation="vertical" >
<ListView
android:id="#+id/dest_List"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="#+id/btn_next" />
<Button
android:id="#+id/btn_next"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="40dp"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:background="#D41016"
android:text="#string/next"
android:textColor="#ffffff"
android:textSize="14dp" />
</RelativeLayout>
</RelativeLayout>
And don't forget to clear the project.

Why doesn't this HorizontalScrollView fills the parent?

I've made a layout that worked fine with a vertical scroll view, but I need to make another one with a horizontal scroll view.
I just changed ScrollView to HorizontalScrollView:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<HorizontalScrollView
android:layout_weight="1"
android:scrollbars="none"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:text="#string/activity_visibilidade_cronologia_aula_subtitulo"
android:textSize="16dp" />
<ImageButton
android:id="#+id/activity_visibilidade_cronologia_aula_btn_info"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:background="#null"
android:scaleType="fitXY"
android:src="#drawable/btn_info" />
</RelativeLayout>
<LinearLayout
android:id="#+id/activity_visibilidade_cronologia_aula_linear_conteudo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
<Button
android:id="#+id/activity_visibilidade_cronologia_aula_btn_confimar"
android:layout_width="165dp"
android:layout_height="35dp"
android:layout_centerVertical="true"
android:layout_gravity="right"
android:layout_marginBottom="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/botao_add_confirmar"
android:text="#string/dialogo_alterar_classe_confirmar"
android:textColor="#color/branco" />
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
And its result is:
Why doesn't HorizontalScrollView fills the parent, is there something wrong?
I solved merging all your advices and also using android:fillViewport="true" my final code is:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<include layout="#layout/layout_titulo_views" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:text="#string/activity_visibilidade_cronologia_aula_subtitulo"
android:textSize="16dp" />
<ImageButton
android:id="#+id/activity_visibilidade_cronologia_aula_btn_info"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:background="#null"
android:scaleType="fitXY"
android:src="#drawable/btn_info" />
</RelativeLayout>
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:scrollbars="horizontal" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:id="#+id/activity_visibilidade_cronologia_aula_linear_conteudo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
</HorizontalScrollView>
<Button
android:id="#+id/activity_visibilidade_cronologia_aula_btn_confimar"
android:layout_width="165dp"
android:layout_height="35dp"
android:layout_centerVertical="true"
android:layout_gravity="right"
android:layout_marginBottom="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/botao_add_confirmar"
android:text="#string/dialogo_alterar_classe_confirmar"
android:textColor="#color/branco" />
</LinearLayout>
</LinearLayout>
Thank you all
I found teh problem. In addition to removing the weight sum, you need to change the linear layout orientation to horizontal.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >

Categories

Resources