【问题标题】:Part of my layout goes upward with keyboard我的部分布局通过键盘向上
【发布时间】:2010-12-24 14:29:43
【问题描述】:

当我打开键盘时,我的 android 应用程序的布局是这样的p>

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

    <LinearLayout
        android:id="@+id/searchLinear"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@color/upperbackground">

           <EditText
            android:id="@+id/searchBox"
            android:layout_alignParentTop="true"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:singleLine="true"
            android:layout_margin="12dip"
            android:paddingLeft="35dip"
            android:textSize="15sp"
            android:background="@drawable/search_bar"/>

    </LinearLayout>

    <LinearLayout
            android:id="@+id/searchButtons"
            android:layout_below="@id/searchLinear"
            android:orientation="horizontal"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center_vertical|center_horizontal"
            android:background="@color/upperbackground">    

        <ImageView
            android:id="@+id/btnSukela"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:clickable="true"
            android:focusable="true"
            android:onClick="sukelaClickEvent"
            android:paddingRight="8dip"
            android:paddingBottom="5dip"
            android:src="@drawable/sukela"/>

        <ImageView
            android:id="@+id/btnSearch"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@+id/btnSukela"
            android:clickable="true"
            android:focusable="true"
            android:onClick="searchEntryClickEvent"
            android:paddingLeft="8dip"
            android:paddingBottom="5dip"
            android:src="@drawable/search"/>

    </LinearLayout>

    <RelativeLayout
        android:id="@+id/bottomLinear"
        android:layout_alignParentBottom="true"
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center_vertical|center_horizontal"
        android:background="@drawable/bottom_back">     

        <ImageView  
            android:id="@+id/btnToday"
            android:src="@drawable/today"
            android:background="@color/bottombackground"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBottom="@+id/bottomLinear"
            android:layout_marginBottom="19dip"
            android:layout_centerVertical="true"
            android:clickable="true"
            android:focusable="true"
            android:onClick="todayClickEvent"/> 

        <ImageView  
            android:id="@+id/btnPopular"
            android:src="@drawable/popular"
            android:background="@color/bottombackground"
            android:layout_toRightOf="@+id/btnToday"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:clickable="true"
            android:focusable="true"
            android:onClick="popularClickEvent"/>

    </RelativeLayout>   

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_below="@+id/searchButtons"
        android:layout_above="@+id/bottomLinear"
        android:background="@color/background">

        <ListView
            android:id="@android:id/list"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>

    </RelativeLayout>

</RelativeLayout>

【问题讨论】:

  • 能发个截图吗?我不明白你的意思是布局调整大小还是图像覆盖在键盘上。

标签: java android android-layout


【解决方案1】:

我认为你需要设置soft input mode:

<activity android:windowSoftInputMode="adjustPan" ...>

在您的清单中,因此当键盘出现时窗口不会调整大小。

【讨论】:

  • 谢谢 jleedev,您的解决方案解决了我的问题,我认为问题是由于布局设计而出现的,但正如您所说的那样,它是“adjustPan”
猜你喜欢
  • 2016-03-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-04-23
相关资源
最近更新 更多