Android布局问题,滚动视图中的几个列表视图
首先,我知道,我不应该将ListView放入ScrollView,因为ListView负责自己的垂直滚动 无论如何,在我的情况下,这是不同的-问题: 我有一个视图,其中显示了一些信息,还有一些操作。 以下是一个示例屏幕: Email1是放置在ListView中的ListItem。主页也是放置在第二个ListView中的ListItem。(我使用了ListView,因为我不能像ListItem和ListView那样设置按钮的样式,另一个原因是,我可以显示第二封邮件:Email2(如果存在)) 无论如何。现在的问题是,布局如下所示:Android布局问题,滚动视图中的几个列表视图,android,listview,layout,styles,scrollview,Android,Listview,Layout,Styles,Scrollview,首先,我知道,我不应该将ListView放入ScrollView,因为ListView负责自己的垂直滚动 无论如何,在我的情况下,这是不同的-问题: 我有一个视图,其中显示了一些信息,还有一些操作。 以下是一个示例屏幕: Email1是放置在ListView中的ListItem。主页也是放置在第二个ListView中的ListItem。(我使用了ListView,因为我不能像ListItem和ListView那样设置按钮的样式,另一个原因是,我可以显示第二封邮件:Email2(如果存在)) 无
(家长)-->
(子家长)-->
-->((它描述电子邮件,或带有主页的“Sonstiges”)-->
(这是列表视图)
我的问题是,当使用ScrollView时,它会将第二个元素切掉,我无法正确地看到它,请看这里:
在这里,我用黄色标记了它,这是我可以单击列表项的地方。它只显示了一点点,第三项甚至不能显示:
我尝试的是删除ScrollView。现在它向我显示了第二项,但在整个视图中,我需要滚动,因为有比我在一个“页面”上看到的更多的信息和操作
一些axml(从上面的屏幕上看是“Aktionen”)其余的看起来完全像这样:
<?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 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>
填补家长的空缺
填补家长的空缺
垂直的
@字符串/背景图片
填补家长的空缺
包装内容
垂直的
填补家长的空缺
包装内容
并且ListItem本身的样式对于这个是不必要的。
我把它改为线性布局,框架布局,相对布局,总是一样的
我希望有人能帮助我。因为这似乎是一个已知的问题,请看这里:,我将自己回答这个问题
至少我对每个元素都使用了ListView。这很有效,但有点不方便,因为每个ListView现在只有一个ListItem。我设法解决了我的时间选择器问题,这可能适用于您和您的ListView。本质上,他们都想要相同的东西,控制触摸事件,因此您必须在Java文件中重写
为此,我在一个单独的Java文件中创建了一个自定义时间选择器,然后在XML中将其作为视图调用
也许您可以创建一个自定义ListView,然后在文件末尾调用以下代码:
@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;
}
第一次触摸事件执行后,视图将获得焦点,这将接管滚动任务。我问了一个关于滚动视图和时间选择器的类似问题,因为时间选择器处理自己的滚动。但没有得到任何答案。我开始担心这是我们不应该做的事情。我真的需要在我的应用程序中使用它虽然我的布局是半空的,但很奇怪…答案是thx,我不能这样做,因为我在和Monodroid一起工作。无论如何,努力+1