繁体   English   中英

键盘弹出时固定布局

[英]fixed layout when keyboard pops up

当我点击edittext时,我有一个listview包含edittext和其他组件,键盘弹出,导致列表视图进入底部并清除edittext中的任何文本

任何想法固定布局或解决这个问题

Item.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/t"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:paddingLeft="7dip"
        android:paddingTop="7dip"
        android:text="Mate name"
        android:textSize="20dip" >
    </TextView>

    <RelativeLayout
        android:id="@+id/relativeLayout1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <Button
            android:id="@+id/n"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:drawablePadding="0dip"
            android:drawableRight="@drawable/icon_name" />

        <EditText
            android:id="@+id/eventname"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_toLeftOf="@+id/n" >
        </EditText>
    </RelativeLayout>

    <TextView
        android:id="@+id/t"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:paddingLeft="7dip"
        android:paddingTop="7dip"
        android:text="Match friend"
        android:textSize="20dip" >
    </TextView>

    <RelativeLayout
        android:id="@+id/relativeLayout1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <Button
            android:id="@+id/buttonpartner"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:drawablePadding="0dip"
            android:drawableRight="@drawable/icon_friend" />

        <EditText
            android:id="@+id/editpartner"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_toLeftOf="@+id/buttonpartner" >
        </EditText>
    </RelativeLayout>

    <TextView
        android:id="@+id/t3"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:paddingLeft="7dip"
        android:paddingTop="7dip"
        android:text="Start Mate date"
        android:textSize="20dip" >
    </TextView>

    <RelativeLayout
        android:id="@+id/relativeLayout1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <Button
            android:id="@+id/d"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:drawablePadding="0dip"
            android:drawableRight="@drawable/icon_cal" />

        <EditText
            android:id="@+id/editd"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_toLeftOf="@+id/d" >
        </EditText>
    </RelativeLayout>

addevent.xml

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

    <ListView
        android:id="@+id/MyList"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:descendantFocusability="beforeDescendants"
         >
    </ListView>

</LinearLayout>

您可以将应用程序设置为全屏模式。 执行此操作时,即使弹出键盘,元素也会固定。

我的一个示例theme.xml文件:

<style name="theme_loading" parent="android:Theme">
    <item name="android:windowBackground">@drawable/loading</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowFullscreen">false</item>
    <item name="android:textSize">14sp</item>
    <item name="android:textColor">@color/textOptionsColor</item>
    <item name="android:radioButtonStyle">@style/rbStyle</item>
    <item name="android:buttonStyle">@style/ButtonStyle</item>
</style>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM