将Horizo​​ntalGridView设置为不在垂直方向上滚动

时间:2016-07-14 14:17:36

标签: android scroll android-gridview

我使用HorizontalGridView创建了产品幻灯片,但我只需要水平滚动滚动条。我尝试setVerticalScrollBarEnable(false)但是没有工作。

我认为问题不在于Scroll,因为这样的运动就像在所有方向上移动所有水平网格一样。

我的部分代码:

public class ListProductsFragment extends android.support.v4.app.Fragment {

private HorizontalGridView gridView;
private OffersAdapter offersAdapter;
private ArrayList<Offer> offers;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);

    offersKey = getArguments().getStringArrayList(Constants.EXTRA_OFFERS_KEYS);

    View view = inflater.inflate(R.layout.list_products_fragment,null);

    gridView = (HorizontalGridView) view.findViewById(R.id.product_gridview);
    gridView.setNumRows(2);
    gridView.setRowHeight(225);

    return view;

}}

我的布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal" android:layout_width="match_parent"
    android:background="@android:color/transparent"
    android:layout_height="500dp">

    <android.support.v17.leanback.widget.HorizontalGridView
        android:id="@+id/product_gridview"
        android:layout_width="match_parent"
        android:layout_height="500dp"
        />

</LinearLayout>

0 个答案:

没有答案