How to make Android ExpandableListView not scrollable? - android

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>

Related

View not visible in device but visible in XML

I am trying to build a layout with a right arrow and a vertical line with 2 textviews to right of it.
This layout will be used in a RecyclerView
This is the code that I am using,
<?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="wrap_content"
android:background="#color/white"
android:clickable="true"
android:id="#+id/rootLayout"
>
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:layout_margin="#dimen/app_margin"
card_view:cardCornerRadius="4dp"
card_view:cardElevation="4dp"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp"
>
<View
android:layout_width="20dp"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:id="#+id/lineView"
android:layout_marginLeft="15dp"
android:background="#color/colorPrimary"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/name"
android:layout_toRightOf="#+id/lineView"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/type"
android:layout_toRightOf="#+id/lineView"
android:layout_below="#+id/name"
/>
<android.support.v7.widget.AppCompatImageView
android:layout_width="50dp"
android:layout_height="50dp"
app:srcCompat="#drawable/right_arrow"
android:layout_alignParentEnd="true"
android:layout_centerInParent="true"
android:id="#+id/right_arrow"
/>
</RelativeLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
This is the result of the above layout
The blue line is not visible when I run the output on my device but is visible in XML as shown
My Questions
How do I make it visible in my device ?
The blue line is very big I tried wrap_content but still did not work
You can simply align your lineView upto the height of text views. otherwise it will grow upto the device height. Refer this sample.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView 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"
android:layout_margin="10dp"
app:cardBackgroundColor="#FFFFFF"
app:contentPadding="10dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical">
<View
android:id="#+id/view"
android:layout_width="20dp"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/linearLayout"
android:layout_alignParentTop="true"
android:background="#color/colorPrimary" />
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="#+id/view"
android:orientation="vertical"
android:padding="10dp">
<TextView
android:id="#+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ABCD"
android:textSize="15sp" />
<TextView
android:id="#+id/value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ABCD"
android:textSize="15sp" />
</LinearLayout>
<ImageView
android:id="#+id/img"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
app:srcCompat="#drawable/ic_keyboard_arrow_right_black_24px" />
</RelativeLayout>
</android.support.v7.widget.CardView>
Screenshot of above example:
To fit the line according to content use this
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white">
<View
android:layout_width="20dp"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:id="#+id/lineView"
android:layout_marginLeft="15dp"
android:background="#color/colorPrimary"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/name"
android:layout_toRightOf="#+id/lineView"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/type"
android:layout_toRightOf="#+id/lineView"
android:layout_below="#+id/name"
/>
<LinearLayout />

Scrollview hiding the textview text in landscape mode

I am trying to use the scrollview to make the textview wrapped within it scrollable.
I am using the grid layout and am able to position the items as I need to, particularly the long text block, wrapped in a scroll view (the text under the big heading).
However, upon rotating , the long text block disappears completely and I have to keep scrolling it up to make it visible. I need it to be visible as expected when in landscape mode.
landscape mode, now visible after swiping up
This is my XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="#layout/toolbar" android:id="#+id/toolbar"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
android:layout_marginTop="20dp"
android:id="#+id/articlesummaryimageview"
android:layout_below="#id/toolbar"
android:layout_centerHorizontal="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/articlesummaryheadingtextview"
android:layout_below="#id/articlesummaryimageview"
android:layout_centerHorizontal="true"
android:textSize="26dp"
android:textStyle="bold"
android:textAlignment="center"
android:layout_marginTop="20dp"
/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="#+id/articlesummaryscreenscrollview"
android:layout_below="#id/articlesummaryheadingtextview"
android:fillViewport="false"
android:layout_above="#+id/showfullarticlebutton"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/articlesummarytextview"
android:textSize="18dp"
android:textAlignment="center"
android:padding="5dp"
/>
</ScrollView>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/showfullarticlebutton"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:textSize="18dp"
android:text="Full Article"
style="#style/AlertDialog.AppCompat.Light"
/>
</RelativeLayout>
Thank you
You're going to have to make your whole layout scrollable or come up with a different design. To make the whole layout scrollable, put the RelativeLayout inside the ScrollView and set the layout_height for the ScrollView to be wrap_content.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/articlesummaryscreenscrollview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<include
layout="#layout/toolbar"
android:id="#+id/toolbar"
/>
<ImageView
android:id="#+id/articlesummaryimageview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/toolbar"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<TextView
android:id="#+id/articlesummaryheadingtextview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/articlesummaryimageview"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:textAlignment="center"
android:textSize="26dp"
android:textStyle="bold"
/>
<TextView
android:id="#+id/articlesummarytextview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:textAlignment="center"
android:textSize="18dp"
android:layout_above="#+id/showfullarticlebutton"
android:layout_below="#id/articlesummaryheadingtextview"
/>
<Button
android:id="#+id/showfullarticlebutton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="Full Article"
android:textSize="18dp"
style="#style/AlertDialog.AppCompat.Light"
/>
</RelativeLayout>
If your business rules don't allow for the entire layout to be scrollable, what you can do is put your ScrollView as the first layout in the XML and adjust your other views layout_above and layout_below to that initial one (basically making that the view that is always shown and everything else adjust around it).
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ScrollView
android:id="#+id/articlesummaryscreenscrollview"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_above="#+id/showfullarticlebutton"
android:fillViewport="false"
>
<TextView
android:id="#+id/articlesummarytextview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:textAlignment="center"
android:textSize="18dp"
/>
</ScrollView>
<TextView
android:id="#+id/articlesummaryheadingtextview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#id/articlesummaryscreenscrollview"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:textAlignment="center"
android:textSize="26dp"
android:textStyle="bold"
/>
<ImageView
android:id="#+id/articlesummaryimageview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#id/articlesummaryheadingtextview"
android:layout_below="#id/toolbar"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
<Button
android:id="#+id/showfullarticlebutton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="Full Article"
android:textSize="18dp"
style="#style/AlertDialog.AppCompat.Light"
/>
</RelativeLayout>
1. Add RelativeLayout as a direct child of ScrollView and put TextView inside it.
2. Use attributge android:fillViewport="true" to ScrollView.
Try this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="#layout/toolbar" android:id="#+id/toolbar"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
android:layout_marginTop="20dp"
android:id="#+id/articlesummaryimageview"
android:layout_below="#id/toolbar"
android:layout_centerHorizontal="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/articlesummaryheadingtextview"
android:layout_below="#id/articlesummaryimageview"
android:layout_centerHorizontal="true"
android:textSize="26dp"
android:textStyle="bold"
android:textAlignment="center"
android:layout_marginTop="20dp" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/articlesummaryscreenscrollview"
android:layout_below="#id/articlesummaryheadingtextview"
android:fillViewport="true"
android:layout_above="#+id/showfullarticlebutton">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/articlesummarytextview"
android:textSize="18dp"
android:textAlignment="center"
android:padding="5dp"
android:text="this is a text"/>
</RelativeLayout>
</ScrollView>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/showfullarticlebutton"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:textSize="18dp"
android:text="Full Article"
style="#style/AlertDialog.AppCompat.Light" />
</RelativeLayout>

Android Layout with Scrollview not at bottom - Fragment

What am I doing wrong that I can't get my "toolbar" to show up at the bottom of the screen (the free and post buttons)? I'm having to wrap this all inside a scroll view so that the keyboard will shift the view when displayed.
=======
UPDATE: Sorry I should have stated that the FREE and POST buttons must be at the bottom of the screen and maintain their size.
This is a FRAGMENT and the mainActivity has been set to android:windowSoftInputMode="adjustResize|adjustPan" however keyboard display is not scrolling the either.
<?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=".CreateFragment">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/red">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/puregreen"
android:id="#+id/createTopView"
android:clickable="false">
<android.support.v7.widget.RecyclerView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/createRecylerView" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:hint="Title"
android:textSize="24sp"
android:id="#+id/createTitleTextView"
android:layout_below="#+id/createRecylerView"
android:layout_alignParentStart="true" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:hint="Description"
android:textSize="18sp"
android:id="#+id/createDescriptionTextView"
android:layout_below="#+id/createTitleTextView"
android:layout_alignParentStart="true" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="+ Tags"
android:id="#+id/createTagsTextView"
android:textSize="18sp"
android:layout_above="#+id/createBottomToolbar"
android:layout_alignParentStart="true" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:id="#+id/createBottomToolbar"
android:layout_alignParentEnd="true">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="FREE"
android:background="#drawable/button_rounded"
android:id="#+id/createCoinButton"
android:layout_alignParentLeft="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="POST"
android:id="#+id/createPostButton"
android:textColor="#ffffff"
android:layout_alignParentRight="true"
android:background="#color/my_blue" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>
I have changed some code please try this code
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
android:layout_width="match_parent"
android:fillViewport="true"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/createTopView"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
android:clickable="false">
<android.support.v7.widget.RecyclerView
android:id="#+id/createRecylerView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_alignParentBottom="true"
android:layout_height="match_parent"
android:layout_below="#+id/createRecylerView">
<EditText
android:id="#+id/createTitleTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/createRecylerView"
android:hint="Title"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="24sp" />
<EditText
android:id="#+id/createDescriptionTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/createTitleTextView"
android:hint="Description"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="18sp" />
<EditText
android:id="#+id/createTagsTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/createBottomToolbar"
android:text="+ Tags"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="18sp" />
<LinearLayout
android:orientation="horizontal"
android:id="#+id/createBottomToolbar"
android:layout_width="match_parent"
android:weightSum="1"
android:layout_height="wrap_content"
>
<Button
android:id="#+id/createCoinButton"
android:layout_width="0dp"
android:layout_weight="0.5"
android:layout_height="match_parent"
android:text="FREE" />
<Button
android:id="#+id/createPostButton"
android:layout_width="0dp"
android:layout_weight="0.5"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="POST"
/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</ScrollView>
Your toolbar is wrapped in a RelativeLayout which is wrapped in another RelativeLayout of which layout_height is set to wrap_content, here it is:
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/red">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" <!-- here -->
android:background="#color/puregreen"
android:id="#+id/createTopView"
android:clickable="false">
Try changing this to match_parent and see if it works.
Why not use linearLayout as the child of scrollView? And set fillViewport property of the scrollView to true to stretch it's contents. Try this code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".CreateFragment">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:background="#color/red">
<LinearLayout
android:id="#+id/createTopView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#color/puregreen">
<android.support.v7.widget.RecyclerView
android:id="#+id/createRecylerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<EditText
android:id="#+id/createTitleTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Title"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="24sp" />
<EditText
android:id="#+id/createDescriptionTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Description"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="18sp" />
<EditText
android:id="#+id/createTagsTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="+ Tags"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="18sp" />
<RelativeLayout
android:id="#+id/createBottomToolbar"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="#+id/createCoinButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="#drawable/button_rounded"
android:text="FREE"
android:textSize="14sp" />
<Button
android:id="#+id/createPostButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:background="#color/my_blue"
android:text="POST"
android:textColor="#ffffff"
android:textSize="14sp" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>

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);

ListView not scrolling.Just Listview

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>

Categories

Resources