Reputation: 5618
First of all - I know, that I shouldn't put a ListView into a ScrollView, because ListView takes care of its own vertical scrolling.
Anyway, in my case it's different - the problem:
I have a View, where I show some Informations and there are also some Actions. Here is an Example-Screen:
Email1 is a ListItem placed in a ListView. Homepage is also a ListItem placed in a second ListView. (I used ListViews, cause I cant style Buttons like I can with ListItem and ListViews - and the other reason is, that I can show up a Second Mail: Email2 if exists)
Anyway. The Problem now is, that the Layout looks like that:
<ScrollView>
(The Parent) --> <LinearLayout>
(SubParent) --> <LinearLayout>
--> ((it describes the Email, or the "Sonstiges", with the Homepage) --> <ListView>
(Here is the ListView)..
The Problem I have is, that when using ScrollView, it cuts the second Element away, I cant see it properly, look here:
Here, where I marked it with yellow, is the place I can click the ListItem.. it shows just a little bit, and a 3rd Item cant even be shown:
What I tried, is, to remove the ScrollView. Well now it shows me the second Item fine, but on this whole View, I need to scroll, cause there are more Informations and Actions than I can see on one "Page".
Some axml (its the "Aktionen", from the upper Screen) the rest looks exactly like this:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
style="@style/ScrollView"
xmlns:local="http://schemas.android.com/apk/res/INMobileCRM4Android.INMobileCRM4Android"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout style="@style/LinearLayout">
<LinearLayout style="@style/LinearLayoutSmall">
<TextView
style="@style/TextAktionen"
android:text="Aktionen" />
<Mvx.MvxBindableListView
local:MvxBind="{'ItemsSource':{'Path':'ActionsList'},'ItemClick':{'Path':'ActionCommand'}}"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:cacheColorHint="#00000000"
local:MvxItemTemplate="@layout/addressshowdataactionlistitem"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
Style:
<style name="LinearLayout" parent="android:Theme">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">fill_parent</item>
<item name="android:orientation">vertical</item>
<item name="android:background">@string/backgroundPicture</item>
</style>
<style name="LinearLayoutSmall" parent="android:Theme">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:orientation">vertical</item>
</style>
<style name="ScrollView" parent="android:Theme">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
</style>
And the Style of the ListItem itself isn't necessary for this. I changed it to LinearLayout, FrameLayout, RelativeLayout, its always the same.
I hope someone can help me..
Upvotes: 0
Views: 1013
Reputation: 3007
I managed to fix my TimePicker issue, this may work for you and your ListViews. Essentially they both want the same thing, control over your touch event so you have to override in your Java file.
I did this by creating a custom TimePicker in a separate Java file and then calling it in the XML as a View.
Maybe you can create a custom ListView and then call the following code at the end of the file:
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
// Stop ScrollView from getting involved once you interact with the View
if (ev.getActionMasked() == MotionEvent.ACTION_DOWN)
{
ViewParent p = getParent();
if (p != null)
p.requestDisallowInterceptTouchEvent(true);
}
return false;
}
After the first touch event is carried out the View will get focus and that will take over Scroll duties.
Upvotes: 1
Reputation: 5618
As it seems to be a known problem, see here: Scrolling with Multiple ListViews for Android, I will answer this question by myself.
At least I used, for every Element, a ListView. That works, but its a little bit unnicely as every ListView has now only one ListItem.
Upvotes: 0