Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 键盘打开时如何设置编辑文本?_Android_Xml_Android Softkeyboard - Fatal编程技术网

Android 键盘打开时如何设置编辑文本?

Android 键盘打开时如何设置编辑文本?,android,xml,android-softkeyboard,Android,Xml,Android Softkeyboard,我有一个活动,其中有带片段的谷歌地图,在底部有一个编辑框。当我点击编辑框时,软键盘显示出来。但我把我的编辑箱藏起来了。那么我怎样才能把我的编辑框放在软键盘上呢。请帮帮我。这是我的密码- <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layout" android:la

我有一个活动,其中有带片段的谷歌地图,在底部有一个编辑框。当我点击编辑框时,软键盘显示出来。但我把我的编辑箱藏起来了。那么我怎样才能把我的编辑框放在软键盘上呢。请帮帮我。这是我的密码-

<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/grey_bg"
android:orientation="vertical" >

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="524dp"
    android:orientation="vertical" >

    <!-- Header -->

    <LinearLayout
        android:id="@+id/relativeLayoutheader"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="0.7"
        android:background="@drawable/header"
        android:orientation="horizontal" >

        <LinearLayout
            android:id="@+id/backLinearLayout"
            android:layout_width="0dip"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:orientation="horizontal"
            android:padding="10dp" >

            <ImageView
                android:id="@+id/imgBack"
                android:layout_width="30dp"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:src="@drawable/back" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="0dip"
            android:layout_height="match_parent"
            android:layout_weight="4"
            android:orientation="horizontal" >

            <TextView
                android:id="@+id/txtLocationName"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:gravity="center"
                android:text="Kommentare"
                android:textColor="@android:color/white"
                android:textSize="16sp" />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/deleteLikeLinearLayout"
            android:layout_width="0dip"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:orientation="vertical" >

            <ImageView
                android:id="@+id/imgTrash"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:src="@drawable/trash"
                android:visibility="gone" />

            <ImageView
                android:id="@+id/imgLike"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:src="@drawable/like"
                android:visibility="gone" />

            <ImageView
                android:id="@+id/imgLiked"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:src="@drawable/like_button_focus"
                android:visibility="gone" />
        </LinearLayout>
    </LinearLayout>

    <!-- Body Part -->

    <LinearLayout
        android:id="@+id/bodyLinearLayout"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="9"
        android:orientation="vertical"
        android:weightSum="10" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="0dip"
            android:layout_weight="3"
            android:orientation="horizontal" >

            <LinearLayout
                android:id="@+id/imgPostLinearLayout"
                android:layout_width="0dip"
                android:layout_height="fill_parent"
                android:layout_weight="1"
                android:orientation="horizontal" >

                <ImageView
                    android:id="@+id/imgPost"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:scaleType="fitXY" />
            </LinearLayout>

            <LinearLayout
                android:id="@+id/mapFragmentLayout"
                android:layout_width="0dip"
                android:layout_height="fill_parent"
                android:layout_weight="1"
                android:orientation="vertical" >

                <ImageView
                    android:id="@+id/imgMap"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:scaleType="fitXY" />

                <!--
                 <fragment
                android:id="@+id/map"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                class="com.google.android.gms.maps.SupportMapFragment" />

                -->
            </LinearLayout>
        </LinearLayout>

        <LinearLayout
            android:id="@+id/listRelatedCommentLinearLayout"
            android:layout_width="fill_parent"
            android:layout_height="0dip"
            android:layout_weight="5.7"
            android:orientation="vertical" >

            <fragment
                android:id="@+id/frag_list"
                android:name="com.handmark.pulltorefresh.extras.listfragment.PullToRefreshListFragment"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_alignParentTop="true" />
            <!--
        <ListView
            android:id="@+id/listRelatedComment"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" >
        </ListView>

            -->

        </LinearLayout>

        <!-- footer -->

        <LinearLayout
            android:id="@+id/footerLinearLayout"
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:background="@drawable/bottom_bar"
            android:orientation="horizontal" >

            <LinearLayout
                android:layout_width="0dip"
                android:layout_height="fill_parent"
                android:layout_weight="3"
                android:orientation="horizontal"
                android:padding="10dp" >

                <EditText
                    android:id="@+id/edtRelatedComments"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_gravity="center"
                    android:background="@drawable/bottom_search"
                    android:hint="Kommentieren…"
                    android:maxLength="140"
                    android:paddingLeft="10dp"
                    android:textSize="13sp" />
            </LinearLayout>

            <LinearLayout
                android:id="@+id/sendButtonLinearLayout"
                android:layout_width="0dip"
                android:layout_height="match_parent"
                android:layout_weight="1.1" >

                <Button
                    android:id="@+id/btnAbsenden"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_gravity="center"
                    android:background="@android:color/transparent"
                    android:gravity="center"
                    android:text="Absenden"
                    android:textColor="@android:color/white"
                    android:textSize="14sp" />
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>
</LinearLayout>

尝试添加

android:windowSoftInputMode="adjustResize"
关于活动。下面是我的代码片段

  <activity
   android:label="@string/app_name"
   android:name=".youractivity" android:windowSoftInputMode="adjustResize">



在您的清单文件中使用此代码,您可以在清单中声明您的活动,您希望在其中输出hope i将为您工作

为什么不使用
adjustResize
我也尝试过它,它正在使用编辑框缩小我的整个布局,它没有给出正确的解决方案。您可以将布局放在滚动视图中。我也尝试过它,但是,因为scrollview保持高度匹配父级,所以下面的LinearLayout保持高度wrapcontent。所以我的整个布局变得混乱。您认为我需要再试一次。请添加调整大小来检查。见我编辑的帖子。它现在应该可以工作了。您还可以执行getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT\u INPUT\u ADJUST\u PAN);在你的活动中动态地。
  <activity
   android:label="@string/app_name"
   android:name=".youractivity" android:windowSoftInputMode="adjustResize">
  <activity
            android:name="youractivity"
            android:windowSoftInputMode="adjustPan|stateAlwaysHidden" />