【问题标题】:How to put fragment on top of soft kevboard?如何将片段放在软 kevboard 上?
【发布时间】:2016-03-08 14:27:50
【问题描述】:

我有一个带有 EditText 的 Android 片段。因为我想在那里输入一些东西,所以我在打开这个片段时也设法显示了键盘。

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
    android:id="@+id/viewgroup_parent"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <LinearLayout
        android:id="@+id/viewgroup_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <View
            android:id="@+id/view_placeholder"
            android:layout_width="match_parent"
            android:layout_height="336dp"
            android:clickable="false"
            android:src="@drawable/img_placeholder_400"
            android:layout_weight="0.64" />

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical"
                android:paddingBottom="@dimen/margin_bot"
                android:paddingLeft="@dimen/margin_left"
                android:paddingRight="@dimen/margin_right"
                android:paddingTop="20dp"
                android:background="@color/dark"
                android:focusableInTouchMode="true"
                android:weightSum="1">

                <RelativeLayout
                    android:orientation="horizontal"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                    <LinearLayout
                        android:orientation="vertical"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentLeft="true"
                        android:layout_alignParentTop="true">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="Enter name"
                            android:id="@+id/textView_fragment_title"
                            android:textColor="@color/white"
                            android:clickable="false" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="You can enter your name here.. "
                            android:id="@+id/textView_fragment_subtitle"
                            android:textColor="@color/blueTone" />
                    </LinearLayout>

                    <ImageButton
                        android:id="@+id/btn_close_fragment_fragment"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:scaleType="center"
                        android:src="@drawable/ic_darkblue_20"
                        android:layout_gravity="right"
                        android:layout_alignParentTop="true"
                        android:layout_alignParentRight="true"
                        android:layout_alignParentEnd="true" />
                </RelativeLayout>

                <EditText
                    android:layout_width="match_parent"
                    android:layout_height="40dp"
                    android:id="@+id/editText_fragment_content"
                    android:background="@color/white"
                    android:inputType="text"
                    android:imeOptions="actionDone"
                    android:hint="Enter name here ..."
                    android:layout_marginTop="10dp">
                    <requestFocus/>
                </EditText>
            </LinearLayout>
        </FrameLayout>
    </LinearLayout>
</LinearLayout>

但是我的键盘在我的片段前面,因此我的片段不再可见。

我想让我的键盘在底部,在我的软键盘顶部,我的片段在这个例子中screenshot

如何将我的 Fragment 放在 Android 软键盘上?

【问题讨论】:

    标签: android-fragments android-softkeyboard android-keypad fragmentmanager


    【解决方案1】:

    以下解决了我的问题:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout
        android:id="@+id/viewgroup_parent"
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:focusableInTouchMode="true"
            android:layout_alignParentBottom="true"
            android:weightSum="1">
            <MY_STUFF>
        </LinearLayout>
    </RelativeLayout>
    

    【讨论】:

      猜你喜欢
      • 2014-07-09
      • 1970-01-01
      • 1970-01-01
      • 2013-02-25
      • 2011-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多