Android列表视图放大无法左右滚动

时间:2016-04-03 03:46:38

标签: android listview

我有listview加载大约50张图片:

<?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"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    android:padding="10dp"
    android:background="@drawable/background">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:focusableInTouchMode="true">

        <ListView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/listViewImg">
        </ListView>

    </LinearLayout>

在活动中,此代码缩放列表视图

final ListView lvi = (ListView)findViewById(R.id.listViewImg);

    try {
        XmlPullParserImg parser = new XmlPullParserImg();
        imgList = parser.parse(getAssets().open(get_xml));
        BinderDataImg binderdata = new BinderDataImg(this, imgHashmap);
        lvi.setAdapter(binderdata);

    }catch(IOException e) {
    e.printStackTrace();
    }

    FloatingActionButton fa1 = (FloatingActionButton) findViewById(R.id.fab1);
    fa1.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        float x1 = lvi.getScaleX();
        float y1 = lvi.getScaleY();
        lvi.setScaleX(x1 * 2);
        lvi.setScaleY(y1 * 2);
    }
    });

我可以放大并缩小列表视图 放大时,我可以上下滚动列表视图,图像比布局大。
但我无法向左和向右滚动(或向左或向右移动)
抱歉我的英语不好 感谢阅读

1 个答案:

答案 0 :(得分:0)

将所有布局和listView的宽度设置为wrap_content而不是match_parent

相关问题