Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 滚动显示图库_Android_Xml - Fatal编程技术网

Android 滚动显示图库

Android 滚动显示图库,android,xml,Android,Xml,我想要的是,当我向上滚动滚动滚动视图时,图库应该打开,当我向下滚动时,surfaceview(摄像头)应该像OLX一样可见。我已经在图中解释了我的要求。希望我以适当的方式解释了我的问题 我已经在这张图中解释了我的要求 我还发布了我的xml代码,让您正确理解 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android

我想要的是,当我向上滚动滚动滚动视图时,图库应该打开,当我向下滚动时,surfaceview(摄像头)应该像OLX一样可见。我已经在图中解释了我的要求。希望我以适当的方式解释了我的问题

我已经在这张图中解释了我的要求

我还发布了我的xml代码,让您正确理解

    <?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"
          tools:context="com.example.ali.ansofexperts.Question_Photo">
    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        />
        <FrameLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@+id/camera_preview">

        </FrameLayout>
         <ScrollView
         android:layout_width="fill_parent"
         android:id="@+id/scrollView"
         android:fillViewport="true"
         android:layout_height="fill_parent"
          >
        <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
        <LinearLayout
            android:layout_width="fill_parent"
            android:minHeight="400dp"
            android:layout_height="wrap_content"
            android:id="@+id/click"
            android:orientation="horizontal">

        </LinearLayout>

        <GridView xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/gridview" android:layout_width="fill_parent"
            android:layout_height="fill_parent" android:columnWidth="90dp"
            android:numColumns="auto_fit" android:verticalSpacing="10dp"
            android:horizontalSpacing="10dp" android:stretchMode="columnWidth"
            android:gravity="center" android:layout_gravity="bottom"
            android:layout_marginTop="400dp"></GridView>
           </RelativeLayout>
       </ScrollView>
   </RelativeLayout>

试试这个

/** A basic Camera preview class */
public class CameraPreview extends SurfaceView implements SurfaceHolder.Callback {
    private SurfaceHolder mHolder;
    private Camera mCamera;

    public CameraPreview(Context context, Camera camera) {
        super(context);
        mCamera = camera;

        // Install a SurfaceHolder.Callback so we get notified when the
        // underlying surface is created and destroyed.
        mHolder = getHolder();
        mHolder.addCallback(this);
        // deprecated setting, but required on Android versions prior to 3.0
        mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    }

    public void surfaceCreated(SurfaceHolder holder) {
        // The Surface has been created, now tell the camera where to draw the preview.
        try {
            mCamera.setPreviewDisplay(holder);
            mCamera.startPreview();
        } catch (IOException e) {
            Log.d(TAG, "Error setting camera preview: " + e.getMessage());
        }
    }

    public void surfaceDestroyed(SurfaceHolder holder) {
        // empty. Take care of releasing the Camera preview in your activity.
    }

    public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
        // If your preview can change or rotate, take care of those events here.
        // Make sure to stop the preview before resizing or reformatting it.

        if (mHolder.getSurface() == null){
          // preview surface does not exist
          return;
        }

        // stop preview before making changes
        try {
            mCamera.stopPreview();
        } catch (Exception e){
          // ignore: tried to stop a non-existent preview
        }

        // set preview size and make any resize, rotate or
        // reformatting changes here

        // start preview with new settings
        try {
            mCamera.setPreviewDisplay(mHolder);
            mCamera.startPreview();

        } catch (Exception e){
            Log.d(TAG, "Error starting camera preview: " + e.getMessage());
        }
    }
}
参考此文档,您可以使用camer…gallery实现surfaceview 你可以试试自己。。


我为初学者发布此参考资料


此参考资料提供了有关我的问题的完整解决方案,希望这会有所帮助。

您试图获得该结果的代码在哪里?我没有在java文件中编写任何代码,因为我不知道如何做。我不知道如何做。好的,但是如果这是您要找的,您将无法在这里获得代码。
希望我以正确的方式解释了我的问题。
没有问题。你说了你想要的,但没有说发生了什么,也没有说发生了什么。至少有一点关于设计的想法我已经完成了表面视图代码。我只需要知道在滚动视图的幻灯片上如何显示图像galleryhi bro…….我有一个疑问,为什么所有的图像没有显示在视图的按钮中,这意味着在RecyclerView中…对我来说,它显示的是一个10到20个图像。。。。