我必须实现下面的屏幕。它在480 * 800像素的屏幕上看起来非常精细。在低分辨率屏幕上,由于屏幕尺寸不足,“结果滚动”会为用户显示非常小的空间,以便滚动显示结果。
实施它的最佳方法是什么?
答案 0 :(得分:4)
我总是发现尝试将滚动的东西滚动到滚动的其他东西是一场噩梦所以我可能会把你的视图的顶部(结果班加罗尔到迈索尔日期)放在ListView标题内,这样它就会滚动屏幕
listView.addHeaderView(listViewHeader);
答案 1 :(得分:2)
他们是对的。您不应将listview放入scrollview。而不是尝试这个:
<ScrollView android:layout_width="fill_parent" android:scrollbars="vertical"
android:layout_height="wrap_content" android:scrollbarStyle="insideOverlay">
<LinearLayout
android:id="@+id/itemContainer"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<!-- YOUR ELEMENTS WILL BE PLACED HERE -->
</LinearLayout>
</ScrollView>
然后你可以从代码中添加项目:
private LinearLayout container;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.YOUR_XML);
container = (LinearLayout)findViewById(R.id.itemContainer);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
/*CREATE YOUR ITEM*/
/*AND PLACE IT INTO CONTAINER*/
container.addView(YOUR_ITEM, layoutParams);
}
答案 2 :(得分:1)
将您在红色边框中显示的部分放在具有自定义列表项的ListView中。我猜你真的不需要滚动视图。只需将排序和过滤按钮设置为父底部即可。按钮和列表项上方部分之间的列表视图。祝你好运。
答案 3 :(得分:1)
我尝试在 ScrollView 中使用 ListView ,在下面的链接中使用我自己的代码作为答案。它对我来说很好。检查一次,如果感觉良好,请尝试一下。
答案 4 :(得分:1)
您可以将ListView放在ScrollView中。只需扩展ListView以覆盖onTouchEvent方法。像这样
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
public class ChildScrollView extends android.widget.ListView {
private int parent_id;
public ChildListView(Context context) {
super(context);
}
public ChildListView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public ChildListView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public boolean onTouchEvent(MotionEvent event){
requestDisallowInterceptTouchEvent(true);
return super.onTouchEvent(event);
}
}
答案 5 :(得分:1)
在这个链接中,我编写了我的解决方案,在scrollview中放置一个可滚动的listview。如果我理解你的问题,我认为它可以帮助你