键盘上方的工具栏

时间:2016-11-11 05:55:23

标签: android android-softkeyboard android-toolbar

我是如何在android studio中的键盘上方添加一个工具栏。编辑文本点击事件显示键盘带工具栏并用工具栏隐藏键盘 这是我的XML代码。

 <LinearLayout
            android:id="@+id/layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:orientation="horizontal">



            <android.support.v7.widget.Toolbar
                android:id="@+id/tool"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                >


                <ImageView
                    android:layout_width="40dp"
                    android:layout_height="30dp"
                    android:src="@mipmap/photo_gray_icon"
                    android:layout_marginLeft="16dp"/>

                <ImageView
                    android:layout_width="40dp"
                    android:layout_height="30dp"
                    android:src="@mipmap/photo_gray_icon"
                    android:layout_marginLeft="16dp"/>

                <ImageView
                    android:layout_width="40dp"
                    android:layout_height="30dp"
                    android:src="@mipmap/photo_gray_icon"
                    android:layout_marginLeft="16dp"/>

                <ImageView
                    android:layout_width="40dp"
                    android:layout_height="30dp"
                    android:src="@mipmap/photo_gray_icon"
                    android:layout_marginLeft="16dp"/>


            </android.support.v7.widget.Toolbar>

        </LinearLayout>

2 个答案:

答案 0 :(得分:0)

在你的清单文件中添加行android:windowSoftInputMode =&#34; adjustPan&#34;对于具有编辑文本的活动

<activity
        android:name="com.ebookread.activity.MainActivity"

        android:windowSoftInputMode="adjustPan" >

答案 1 :(得分:0)

在onCreate

中添加此行
class User(model.Model):
    username = model.CharField('username', max_length=10)

class Question(model.Model):
    title = models.CharField('title', max_length=10)

class Answer(model.Model):
    user = model.ForeignKey(User)
    question = model.ForeignKey(Question)
    body = model.TextField('the answer body')