Android 焦点上的编辑文本向上滚动,不调整其他视图的大小
我正在尝试获取一个EditText字段,以便在选中时在cameraPreview上滚动。然而,它现在正在调整cameraPreview的大小。我会满足于一个adjustPan行为,但我希望actionBar保持在屏幕上。我怀疑它可以通过scrollView来完成,但是不,我不能阻止cameraPreview调整大小Android 焦点上的编辑文本向上滚动,不调整其他视图的大小,android,xml,android-edittext,scrollview,adjustpan,Android,Xml,Android Edittext,Scrollview,Adjustpan,我正在尝试获取一个EditText字段,以便在选中时在cameraPreview上滚动。然而,它现在正在调整cameraPreview的大小。我会满足于一个adjustPan行为,但我希望actionBar保持在屏幕上。我怀疑它可以通过scrollView来完成,但是不,我不能阻止cameraPreview调整大小 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="
<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>
最终决定滚动整个视图,包括操作栏我已经搜索解决方案很久了,终于找到了 很简单 首先,使用scroll_view作为您的视图,它有一个edit_text子视图 第二,使用相对布局(线性布局是无用的)作为滚动视图的子级 然后,你可以看到它的工作 注意:(1)不要使用布局\对齐\父级\底部,而是使用下面的用户布局\底部 (2) 无需指定窗口\软\输入\模型,默认为OK 这是一个例子
<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>
`在这里输入代码`
`在这里输入代码
android:windowSoftInputMode="stateHidden|adjustResize|adjustPan"
在清单活动中添加上述行