Android陷入布局和列表视图

时间:2012-09-27 11:15:35

标签: android listview layout

直接查看屏幕快照以便轻松理解......

这是正常的屏幕..!

enter image description here

但是当我点击edittext时,它看起来像这样..

enter image description here

我正在使用相对布局的信息看看..

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="@drawable/back"
android:orientation="vertical"
android:visibility="visible" >

<include
    android:id="@+id/include1"
    layout="@layout/titlebar_layout" />

<LinearLayout
    android:id="@+id/linearLayout1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:gravity="center" >

    <ListView
        android:id="@+id/lvcategory"
        android:layout_width="320dp"
        android:layout_height="334dp"
        android:cacheColorHint="@color/Transpaternt_color" >
    </ListView>

</LinearLayout>

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/include1"
    android:text="Recenter Map At : "
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="@color/Text_color" />



<EditText
    android:id="@+id/edtaddress"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView1"
    android:layout_centerHorizontal="true"
    android:editable="true"
    android:ems="10"
    android:enabled="true"
    android:hint="@string/Address"
    android:textColorHint="@color/Hint_color" />

<Button
    android:id="@+id/btngo"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/edtaddress"
    android:layout_alignBottom="@+id/edtaddress"
    android:layout_alignParentRight="true"
    android:text="Go" />

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/edtaddress"
    android:text="Categories : "
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="@color/Text_color" />

</RelativeLayout>

那怎么解决这个问题?任何帮助将不胜感激..谢谢提前

2 个答案:

答案 0 :(得分:2)

用这个替换你的xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="@drawable/back"
android:orientation="vertical"
android:visibility="visible" >

<include
    android:id="@+id/include1"
    layout="@layout/titlebar_layout" />


<ListView
    android:id="@+id/lvcategory"
    android:layout_width="match_parent"
    android:layout_height="324dp"
    android:layout_alignParentBottom="true"
    android:layout_below="@+id/textView2"
    android:cacheColorHint="@color/Transpaternt_color" >

</ListView>

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/include1"
    android:text="Recenter Map At : "
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="@color/Text_color" />



<EditText
    android:id="@+id/edtaddress"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView1"
    android:layout_centerHorizontal="true"
    android:editable="true"
    android:ems="10"
    android:enabled="true"
    android:hint="@string/Address"
    android:textColorHint="@color/Hint_color" />

<Button
    android:id="@+id/btngo"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/edtaddress"
    android:layout_alignBottom="@+id/edtaddress"
    android:layout_alignParentRight="true"
    android:text="Go" />

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/edtaddress"
    android:text="Categories : "
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="@color/Text_color" />

</RelativeLayout>

希望您了解在您的情况下不应将ListView与任何布局一起使用。

答案 1 :(得分:0)

尝试这可能是使用完全调整清单

<activity
  android:windowSoftInputMode="adjustResize"              
  android:name=".youractivity" android:label="@string/app_name" >