首页 > 解决方案 > 将gridview与其他项目一起使用时滚动整个屏幕

问题描述

我有一个显示一些项目“图像和按钮”的片段我想滚动所有屏幕,而不仅仅是网格视图,我进行了一些搜索并使用了一些代码,但它卖不出去,所以我该怎么做...... ………………………………………………………………………………………………………………………………………… ………………………………………………………………………………………………………………………………………… ..................................................... .....................

这是问题4 秒

我的代码

<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:overScrollMode="never"
android:scrollbars="none"
tools:context=".Fragment.ImagesFragmentProject.HomeImagesFragment">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FFFFFF">

    <!-- editor's chooses text -->
    <TextView
        android:id="@+id/choose_text2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/scrollView_image"
        android:paddingTop="20dp"
        android:paddingRight="10dp"
        android:paddingBottom="6dp"
        android:text="إختيار المحررين"
        android:textColor="@color/colorBlack"
        android:textSize="18sp"
        android:textStyle="bold" />

    <GridView
        android:id="@+id/gridview_image_choose"
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/choose_text2"
        android:background="#fff"
        android:columnWidth="100dp"
        android:fastScrollEnabled="false"
        android:gravity="center"
        android:horizontalSpacing="0dp"
        android:numColumns="auto_fit"
        android:paddingTop="8dp"
        android:scrollbars="none"
        android:stretchMode="columnWidth"
        android:verticalSpacing="0dp" />
</RelativeLayout>

Java 类

public class HomeImagesFragment extends Fragment {

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

    /* ArrayList for chooseImages */
    final String[] chooseImages = {
            "https://i1.wp.com/www.newphotodownload.info/wp-content/uploads/2018/12/%D8%A8%D9%88%D8%B3%D8%AA%D8%A7%D8%AA-%D8%AF%D9%8A%D9%86%D9%8A%D8%A9-61-1.jpg",
            "https://quotess.cc/wp-content/uploads/2020/01/4688.jpg",
            "https://whatt.cc/wp-content/uploads/2018/07/4443.jpg",
            "https://i1.wp.com/www.newphotodownload.info/wp-content/uploads/2018/12/%D8%A8%D9%88%D8%B3%D8%AA%D8%A7%D8%AA-%D8%AF%D9%8A%D9%86%D9%8A%D8%A9-61-1.jpg",
            "https://quotess.cc/wp-content/uploads/2020/01/4688.jpg",
            "https://whatt.cc/wp-content/uploads/2018/07/4443.jpg",
            "https://i1.wp.com/www.newphotodownload.info/wp-content/uploads/2018/12/%D8%A8%D9%88%D8%B3%D8%AA%D8%A7%D8%AA-%D8%AF%D9%8A%D9%86%D9%8A%D8%A9-61-1.jpg"
    };

    /* make new object and find the view "GridView" */
    GridView gridview1 = rootView.findViewById(R.id.gridview_image_choose);
    // display all the images from Array on it
    gridview1.setAdapter(new PicassoImagesAdapter(getActivity(), chooseImages));


    /* display the image when click on it */
    // we made a class for this method called "PicassoDisplayImageAdapter"
    gridview1.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // get the image
            String image = chooseImages[position];
            Intent intent = new Intent(getActivity(), PicassoDisplayImageAdapter.class);
            intent.putExtra("imageUrl", image);
            getActivity().startActivity(intent);
        }
    });

    return rootView;

}

}

标签: javaandroid

解决方案


推荐阅读