在相机预览版上放置ImageView
问题描述:
因此,我有一个使用的xml布局,它有两个主要元素,一个包含相机预览的framelayout和一个imageview。图像视图应该在framelayout上可见,并且直到camerapreview被打开,然后才被推到后面。我究竟做错了什么?在相机预览版上放置ImageView
我做了很多测试,从布局和重建中删除元素,我似乎无法修复错误的原因,我相信原因必须在代码中的某个地方。
答
我认为应该推动它,因为是RelativeLayout
。我认为你应该使用LinearLayout
。在RelativeLayout
中属性android:layout_weight="1"
也是无效参数。
你可以尝试,并迫使图像视图对齐顶部:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="390dip"
android:layout_marginTop="25dip">
<ImageView
android:id="@+id/imageView1"
android:layout_width="300dip"
android:layout_height="305dip"
android:background="#00000000"
android:layout_alignParentTop="true"
android:src="@drawable/try_3"
android:visibility="visible"
android:layout_marginLeft="10dip"/>
<FrameLayout
android:id="@+id/previewframe1"
android:layout_width="320dip"
android:layout_height="310dip"
android:layout_alignParentTop="true"
>
</FrameLayout>
</RelativeLayout>
希望有所帮助。
答
请为透明度设置ImageView的背景和/或其包含的布局android:background =“@ null”。
+0
我刚刚尝试过,但没有任何改变 – Peter 2012-08-01 23:53:05
如何将它们放在彼此的顶部,如果它的LinearLayout?此外,它的作品,当我不打开相机预览,但一旦我把它打破。我确实删除了重量 – Peter 2012-08-01 23:48:49
看看我的编辑,看看是否你想要的。 – 0gravity 2012-08-01 23:53:57
还是没有im抱歉,我认为这个问题是与相机预览类或代码 – Peter 2012-08-01 23:57:25