我在高度= match_parent
的滚动视图中放置了一个编辑文本,并期望其高度等于滚动视图,但事实并非如此。它的高度就像wrap_content
一样,这意味着如果EditText中没有文本,我将必须将光标指向第一行,软键盘才能弹出,我想要的是我可以触摸屏幕上的任意位置(滚动视图),然后弹出软键盘。
下面是布局,感谢您的帮助。
<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:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:gravity="top"
android:padding="10dp"
android:textSize="16sp"
android:textColor="@android:color/black">
</EditText>
</ScrollView>
<Button
android:id="@+id/btnPaste"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/paste"
android:gravity="center"
android:onClick="pasteData"
android:layout_marginLeft="5dp"
android:layout_marginRight="6dp"
android:layout_marginBottom="5dp"
android:background="@drawable/rounded_corner_button"
android:textColor="@android:color/white"/>
</LinearLayout>
布局捕获:
最佳答案
在ScrollView中添加此行。android:fillViewport="true"