各位,有谁在Android3.0平台上开发过程序没?最近在3.0上做开发,遇到了一些问题,请教一下大家,问题如下:设计的界面在eclipse中显示正常,但是运行之后界面总是只能在模拟器中间1/3的那部分显示,不能占满整个屏幕,实在搞不懂为什么。显示结果如下图:UI布局代码如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:gravity="center"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView android:layout_width="match_parent"
android:id="@+id/login_iv"
android:layout_height="wrap_content"
android:src="@drawable/jl2"
android:layout_marginBottom="66sp">
</ImageView>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_marginBottom="14sp"
android:gravity="center_horizontal"
android:layout_width="545sp">
<TextView android:textSize="30sp"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginRight="10sp"
android:text="@string/server">
</TextView>

<Spinner android:layout_width="300px"
android:layout_height="wrap_content"
android:id="@+id/choose_server_sp">
</Spinner>

<Button android:layout_height="wrap_content"
android:text="@string/update_server"
android:id="@+id/update_bt"
android:layout_marginLeft="12sp"
android:textSize="20sp" android:layout_width="77sp">
</Button>
</LinearLayout>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_marginBottom="14sp"
android:layout_width="535sp"
android:gravity="center_horizontal">
<TextView android:textSize="30sp"
android:layout_height="wrap_content"
android:text="@string/user_type" android:layout_width="wrap_content">
</TextView>

<Spinner android:layout_width="300px"
android:layout_height="wrap_content"
android:id="@+id/type_sp" android:layout_marginLeft="10sp">
</Spinner>
</LinearLayout>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_marginBottom="14sp"
android:layout_width="535sp"
android:gravity="center_horizontal">
<TextView android:textSize="30sp"
android:layout_height="wrap_content"
android:layout_width="wrap_content" 
android:text="@string/username">
</TextView>

<EditText android:textSize="30sp"
android:layout_height="wrap_content"
android:layout_width="300px"
android:id="@+id/username_et"
android:layout_marginLeft="10sp"
android:hint="@string/input_username">
</EditText>
</LinearLayout>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_marginBottom="24sp"
android:layout_width="535sp"
android:gravity="center_horizontal">
<TextView android:textSize="30sp"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/psw">
</TextView>

<EditText android:textSize="30sp"
android:layout_height="wrap_content"
android:layout_width="300px"
android:inputType="textPassword"
android:id="@+id/password_et"
android:layout_marginLeft="10sp"
android:hint="@string/input_psw">
</EditText>
</LinearLayout> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="wrap_content">
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/login"
android:id="@+id/login_btn"
android:textSize="30sp">
</Button>

<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/exit"
android:id="@+id/cancel_btn"
android:layout_marginLeft="10sp"
android:textSize="30sp">
</Button>
</LinearLayout></LinearLayout>

解决方案 »

  1.   

    有人遇到过这种问题吗,或者有人在android3.0上开发过程序吗?求助啊。
      

  2.   

    主要还是你layout文件的问题。很多地方你都写死了。
      

  3.   

    请问:为什么在eclipse中显示正常,而到了模拟器中就不行了呢?如果不写死,要怎么修改呢?
      

  4.   

    控件的长宽都改成自适应"wrap_content"试试吧!
      

  5.   

    试了一下,还是不行。。快要纠结死了。。为什么开发android3.0的人这么少啊?难道是因为以前的不开源????
      

  6.   


    eclipse中能下常显示,你说的这个是ADT中的UI编辑功能??如果你在这个当中能正常显示,并不能保证就能在模拟器和真机上正常显示。模似器和真机可能会有不同的屏幕分辨率,所以你针对一种大小写的layout到不同的大小的屏幕上当然要有问题了。所以最好不要写死,可以用dip代替sp。
      

  7.   

    您的布局有问题,请不要将所有的线性布局写死,并且在设计长、宽的时候,您使用了SP方式设置大小,一般SP单位使用在字体上,而dip更适合使用在布局大小上。
       您出现的问题应该就在设备的分辨上,平板的电脑的密度比较小,而模拟器上的密度比较大,所以致使了这个悲俱发生
      

  8.   

    呵呵,樓主啊 我也遇到同樣問題,你要記得設置android:minSdkVersion="11" 
    就可以了,3.0比較奇怪一點~
      

  9.   

    楼主,可以问个问题了,你的界面全屏怎么实现的啊?android3.0下方的System Bar怎么隐藏的啊