Java 如何在页面的某一部分中获得ZXing扫描仪?

Java 如何在页面的某一部分中获得ZXing扫描仪?,java,android,android-fragments,fragment,zxing,Java,Android,Android Fragments,Fragment,Zxing,我现在使用的是稍微熟悉一点,从现在开始,主屏幕如下所示: 当您按下“扫描”按钮时,它将全屏打开扫描仪,并将方向锁定为横向。现在,我希望它只在主屏幕的一部分打开,而不是扫描器打开全屏。换句话说,扫描仪应仅位于红色框内: 我稍微改变了主屏幕的布局,使片段显示在按钮下方: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.co

我现在使用的是稍微熟悉一点,从现在开始,主屏幕如下所示:

当您按下“扫描”按钮时,它将全屏打开扫描仪,并将方向锁定为横向。现在,我希望它只在主屏幕的一部分打开,而不是扫描器打开全屏。换句话说,扫描仪应仅位于红色框内:

我稍微改变了主屏幕的布局,使片段显示在按钮下方:

<LinearLayout 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:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".HomeActivity"
android:orientation="vertical">

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:gravity="center_horizontal">

<TextView
    android:text="@string/hello_world"
    android:id="@+id/tv_welcome"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="@dimen/activity_vertical_margin"/>
<TextView
    android:text="@string/blog_url"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/tv_blog_url"
    android:layout_marginBottom="@dimen/activity_vertical_margin"/>

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/btn_scan_now"
    android:onClick="scanNow"
    android:layout_marginBottom="@dimen/activity_vertical_margin"
    android:id="@+id/btn_scan_now" />

<TextView
    android:id="@+id/scan_format"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textIsSelectable="true"
    android:gravity="center_horizontal"
    android:layout_marginBottom="@dimen/activity_vertical_margin" />
<TextView
    android:id="@+id/scan_content"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textIsSelectable="true"
    android:layout_marginBottom="@dimen/activity_vertical_margin"
    android:gravity="center_horizontal" />

</LinearLayout>


<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/scan_fragment"
    android:orientation="horizontal"></LinearLayout>
</LinearLayout>

在下面的第一张图片中,您将看到我在自己的应用程序中试图实现的目标。第二个是我目前所拥有的。黑色部分是我想让扫描仪去的地方。目前,所有这些都是为片段保留的线性布局:

但这就是我停滞不前的地方。我不确定如何防止扫描仪全屏和横向扫描,以及将其锁定到页面的特定区域。有谁能为如何实现这一目标提供一些指导


提前感谢您的帮助。

ZXing启动了自己的活动,因此您无法做自己想做的事情,请使用android mobile vision api@tyczj。对于我可以使用的不同扫描仪库,您还有其他建议吗?编辑:哦,没关系,我误读了你的评论,我会调查API的。