Android framelayout中的Imageview不可见

Android framelayout中的Imageview不可见,android,imageview,android-framelayout,Android,Imageview,Android Framelayout,嗨,我正在开发一个android视频应用程序。我在框架布局中有一个按钮,如下代码所示 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orien

嗨,我正在开发一个android视频应用程序。我在框架布局中有一个按钮,如下代码所示

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<FrameLayout
    android:id="@+id/videoview"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <Button
        android:id="@+id/camerabutton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="right"
        android:drawableTop="@drawable/videocamera"
        android:text="REC"
        android:textSize="12dp" />
</FrameLayout>

</RelativeLayout>
其中getCameraInstance如下所示

private Camera getCameraInstance()
{
    try 
    {
        c = Camera.open(); // attempt to get a Camera instance
    }

    catch (Exception e)
    {
        // Camera is not available (in use or does not exist)
    }
    return c; // returns null if camera is unavailable
}
MyCameraSurfaceView
如下所示-

public class MyCameraSurfaceView extends SurfaceView 
                                    implements SurfaceHolder.Callback{

    private SurfaceHolder mHolder;
    private Camera mCamera;

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

        mHolder = getHolder();
        mHolder.addCallback(this);
        // deprecated setting, but required on Android versions prior to 3.0
        mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    }

    @Override
    public void surfaceChanged(SurfaceHolder holder, int format, int weight,
            int height)
    {
        if (mHolder.getSurface() == null)
        {
            // preview surface does not exist
            return;
        }

        try 
        {
            mCamera.stopPreview();
        } 
        catch (Exception e)
        {

        }

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

        } 
        catch (Exception e)
        {
        }
    }
框架布局中的按钮不可见。我对框架布局知之甚少。我不知道如何使按钮可见<请
救命啊。谢谢

从ImageView中删除文本和文本大小

<ImageView
    android:id="@+id/camerabutton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="right"
    android:src="@drawable/videocamera" />


如果问题仍然存在,请发布屏幕截图。

如果您希望图像和文本都显示在视图中,请使用按钮

<FrameLayout
    android:id="@+id/videoview"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <Button
        android:id="@+id/camerabutton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="right"
        android:drawableTop="@drawable/ic_launcher"
        android:text="REC"
        android:textSize="12dp" />
</FrameLayout>

试试这个,我们希望右侧使用这个
android:layout\u gravity=“right”


只需在将预览添加到帧视图之前添加这些行即可

FrameLayout.LayoutParams previewLayoutParams=新建FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_内容,FrameLayout.LayoutParams.WRAP_内容)


添加视图(mPreview,0,previewLayoutParams)

一切看起来都很好,到底是什么问题?你在期待什么?
android:src=“@drawable/videocamera”
代替这个try
android:background=“@drawable/videocamera”
@AhmedEkri我已经用确切的问题更新了我的问题。我已经如上所述进行了更改。同样的问题仍然存在。我已经编辑了我的问题。我需要对其进行哪些更改。请注意,我已经编辑了我的问题。我需要对其进行哪些更改。请导游。
<FrameLayout
    android:id="@+id/videoview"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <Button
        android:id="@+id/camerabutton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="right"
        android:drawableTop="@drawable/ic_launcher"
        android:text="REC"
        android:textSize="12dp" />
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:orientation="vertical" >

 <FrameLayout
android:id="@+id/videoview"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<ImageView
    android:id="@+id/camerabutton"
    android:layout_width="match_parent"
    android:layout_height="match_parent"        
    android:background="@drawable/com_facebook_button_check"
    android:text="REC"
    android:textSize="12dp" />
  </FrameLayout>

  </RelativeLayout>