1

I'm fairly new into Xamarin/Android development and currently facing the following problem:

I have an Activity with a dozen input controls formatted with a TableLayout inside a ScrollView. Also there's a ListView which gets filled with data from an SQLite table onCreate() and rendered as CheckBox-List. I can see all elements (currently four) if the keyboard is not visible. As soon as the keyboard is visible and I scroll down to the ListView only one element is left clickable. I tried some proposed solutions from other threads (like this) but it still does not work.

Here's the essential layout:

<ScrollView>
...
<ListView />
...
</ScrollView>

The activity is set to android:windowSoftInputMode="stateVisible|adjustResize"

I'm not sure if I'm even using the right layout element or if I should use some other way to programmatically generate checkboxes from my SQLite table?

Community
  • 1
  • 1
Adan0s
  • 23
  • 5
  • Aside from the technical issue, this also sounds like an UX issue. Maybe rethink how you display the controls and the data? – Jordy Langen Apr 18 '16 at 20:08
  • Not possible. It's a LOB App which is only used to collect information for specific goods. and depending on which category it is there are some "features" which need to be checked. It works quite well (using this design since 3 years in a win8 app). It's not like there will be ever 1000 checkboxes. :) – Adan0s Apr 18 '16 at 20:18
  • I guess ScrollView is creating problems. Try putting ListView outside of ScrollView. – Shadab Ansari Apr 18 '16 at 20:18
  • The ListView also needs to be able to be scrolled to when the keyboard is visible. So I can't do that. :/ – Adan0s Apr 18 '16 at 20:45
  • If the checkbox list is pretty small you might want to look at manually generating the checkboxes with a simple loop. You really should never put a listview inside of a scroll view. It causes all sorts of issues. – Andres Castro Apr 18 '16 at 21:05

2 Answers2

1

Welcome to the Xamarin world!

First of all you should follow the approach of not nesting a ListView inside a ScrollView or vice versa , it will simply cause you lots of issues with the UX which you want to avoid.

Secondly this is a well known issue which occurs due to a bug on Xamarin Forms.

Setting the WindowSoftInputMode attribute to the activity itself doesn't work exactly because of the bug, so you must explicitly set this attribute by adding this line of code below the

LoadApplication(new App());

call :

Xamarin.Forms.Application.Current.On<Xamarin.Forms.PlatformConfiguration.Android>().UseWindowSoftInputModeAdjust(WindowSoftInputModeAdjust.Resize);
MalokuS
  • 446
  • 3
  • 12
0

A scrollview can have only one child. Put a linearlayout (orientation vertical) as the only child of your scrollview. Then put your items (and your listview) in this linearlayout.

Softlion
  • 12,281
  • 11
  • 58
  • 88