0

我试图让 EditText 字段在选中时滚动到我的 cameraPreview 上。然而,它现在正在调整 cameraPreview 的大小。我会对 adjustPan 行为感到满意,但是我希望 actionBar 留在屏幕上。我怀疑它可以用 scrollView 来完成,但是我不能阻止 cameraPreview 调整大小。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="fill_parent"
tools:context=".MainActivity" >
    <FrameLayout
    android:id="@+id/cameraPreview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/transparent" >

    </FrameLayout>

<!-- Fix for black overlay on menu -->
<FrameLayout 
    android:layout_width="match_parent"
    android:layout_height="match_parent" 
    android:background="@android:color/transparent" >
</FrameLayout>
<ScrollView 
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:isScrollContainer="true"
        >
      <EditText
        android:id="@+id/inputCode"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:background="@color/White"
        android:ems="10"
        android:inputType="textNoSuggestions"
        android:maxLines="1"
        android:textColor="@color/Green"
        android:textSize="32sp"
        android:layout_alignParentBottom="true" >

    </EditText>
 </ScrollView>

变形的苹果

4

3 回答 3

0

最后决定滚动整个视图,包括操作栏

于 2014-03-01T16:20:27.980 回答
0

找了好久,终于搞定了;

这很简单,

首先,使用 scroll_view 作为你的视图,它有一个 edit_text 孩子;

其次,使用Relative_Layout(Linear_Layout 没用)作为Scroll_View 的子级

然后,你可以看到它的工作说明:(1)不要使用 layout_align_Parent_Bottom ,用户 layout_below 代替(2)您无需指定 window_Soft_Input_Model,默认即可;

这是示例

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rootlinearlayout"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<ScrollView
    android:id="@+id/scrollView1"
    android:layout_width="match_parent"
    android:layout_height="500dp"
    android:text="@string/hello_world" >

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

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="64dp"
            android:text="Button1" />

        <Button
            android:id="@+id/button6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Button6" />

        <Button
            android:id="@+id/button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Button2" />

        <Button
            android:id="@+id/button3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Button3" />

        <Button
            android:id="@+id/button4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Button4" />

        <EditText
            android:id="@+id/editText1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/scrollView1"
            android:ems="10" >
        </EditText>

        <Button
            android:id="@+id/button8"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Button8" />

        <Button
            android:id="@+id/button9"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Button9" />

        <Button
            android:id="@+id/button10"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Button10" />

        <Button
            android:id="@+id/button5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Button5" />
    </LinearLayout>
</ScrollView>

<LinearLayout
    android:id="@+id/captionbottomrelativelayout"
    android:layout_width="320dp"
    android:layout_height="44dp"
    android:layout_below="@+id/scrollView1"
    android:orientation="horizontal" >

    <Button
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:text="Button" />`enter code here`
</LinearLayout>

`在此输入代码

于 2014-05-23T10:06:35.720 回答
0
android:windowSoftInputMode="stateHidden|adjustResize|adjustPan"

在您的清单活动中添加上述行。

于 2017-11-04T12:12:54.257 回答