我想知道是否有某种方法可以让相机预览填充屏幕的一部分,并且在底部有一个textview框供我稍后添加文本。 我还没有任何代码,因为在继续执行代码之前,我的团队仍在评估这是否可行。是否可以在相同的屏幕上显示Camera Preview和TextView?
编辑2:现在我终于能够在玩android:gravity之后看到屏幕上的文字。但是TextView总是显示在屏幕的顶部,有什么方法可以将它移动到底部?
编辑3:改变机器人:layout_height到FILL_PARENT代替WRAP_CONTENT固定的定位问题
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<SurfaceView android:id="@+id/preview_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true"/>
<com.google.zxing.client.android.ViewfinderView
android:id="@+id/viewfinder_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/transparent"/>
........
........
<TextView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="bottom"
android:text="Header text"/>
</FrameLayout>
感谢您的回答,我应该提到的是,我发现了摄像头预览实际上是从斑马线的条码扫描器延长。我想减少相机预览尺寸,并在底部有一个Textview。我尝试添加TextView作为你们两个人的建议,但我无法看到任何区别。为了您的参考,我将附上zxing xml文件 –
它现在可以使用!但是有一个小问题,我编辑了我的帖子以包含我正在处理的代码。重力似乎不能正常工作:/我需要线性布局吗? –
您使用了'android:layout_height =“wrap_content”',而它应该是'fill_parent'来表示水平重力以使感觉/工作。 – inazaruk