当键盘显示时,部分布局消失

时间:2012-10-04 06:27:18

标签: android android-layout

我有一个布局,其中包含标题和列表的一些部分:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/bisque">
    <LinearLayout 
        xmlns:treeView="http://schemas.android.com/apk/res/com.spot.p2a"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_toLeftOf="@+id/backArrow"
        android:orientation="vertical" 
        android:weightSum="100"
        android:background="@color/antiquewhite">

        <LinearLayout
            android:id="@+id/email_listview_top"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="20"
            android:orientation="vertical"
            android:background="@color/bisque" >

            <TextView
                android:id="@+id/email_listview_header"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/pdf_mail_versand_text"
                android:textColor="@color/black"
                android:layout_marginTop="30dp"
                android:layout_marginLeft="20dp"
                android:textStyle="bold"
                android:textSize="24dp" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginTop="20dp"
                android:orientation="vertical" 
                android:background="@color/antiquewhiter">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="5dp"
                android:orientation="vertical" 
                android:background="@color/antiquewhite">
            </LinearLayout>
                <TextView
                    android:id="@+id/headList"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/datenblätter_text"
                    android:textColor="@color/black"
                    android:layout_marginLeft="20dp"
                    android:layout_marginTop="20dp"
                    android:textStyle="bold"
                    android:textSize="14dp" />

            </LinearLayout>

        </LinearLayout>

         <pl.polidea.treeview.TreeViewList 
            android:id="@+id/tree" 
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="80"
            android:background="@color/antiquewhiter" 
            treeView:indicator_gravity="right|center_vertical"
            android:scrollbars="vertical" 
            android:smoothScrollbar="true"/>


    <!--     <ListView  -->
    <!--         android:id="@android:id/list" -->
    <!--         android:layout_width="match_parent" -->
    <!--         android:layout_height="0dp" -->
    <!--         android:layout_weight="80"  -->
    <!--         android:fadingEdge="none" -->
    <!--         android:background="@color/antiquewhiter" -->
    <!--         android:divider="@color/bisque" -->
    <!--         android:dividerHeight="2dp" -->
    <!--         android:visibility="gone" -->
    <!--         > -->
    <!--     </ListView> -->

    </LinearLayout>
    <ImageView
        android:id="@+id/backArrow"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:visibility="gone"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:src="@drawable/back_android" />
</RelativeLayout>

当我在手机上显示键盘时:

<LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_marginTop="20dp"
                    android:orientation="vertical" 
                    android:background="@color/antiquewhiter">
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="5dp"
                    android:orientation="vertical" 
                    android:background="@color/antiquewhite">
                </LinearLayout>
                    <TextView
                        android:id="@+id/headList"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/datenblätter_text"
                        android:textColor="@color/black"
                        android:layout_marginLeft="20dp"
                        android:layout_marginTop="20dp"
                        android:textStyle="bold"
                        android:textSize="14dp" />

                </LinearLayout>

            </LinearLayout>

disapear。我不知道为什么。当我隐藏键盘这个部分再次显示。如果有人有这个问题,请解释为什么键盘在屏幕上显示时某些部分是隐藏的?

2 个答案:

答案 0 :(得分:4)

在“AndroidManifest”文件中的活动中尝试此操作。

<activity android:windowSoftInputMode="adjustResize|adjustPan">

了解更多信息: -

https://developer.android.com/guide/topics/manifest/activity-element.html#wsoft

答案 1 :(得分:1)

了解Android windowSoftInputMode

因此,您可以将以下语句中的“调整大小”模式更改为“AndroidManifest”中的活动。

<activity android:name=".YourActivity"
            android:windowSoftInputMode="adjustResize">
相关问题