简体   繁体   English

Android在2.x和4.x上的不同可视化

[英]Android different visualization on 2.x and 4.x

I'm having some trouble about visualization of items. 我在项目可视化方面遇到了一些麻烦。 On android 2.x xml fill the screen but in 4.x they cover about 50% of the screen and the other 50% it's all black. 在android 2.x xml上填充屏幕,但在4.x中它们覆盖约50%的屏幕,其余50%则全是黑色。 I think using fill_parent and wrap_content help me! 我认为使用fill_parent和wrap_content可以帮助我! How i can standardize it ? 我如何使其标准化? Here's the source 这是来源

     <?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="wrap_content"
      android:orientation="vertical"
      android:background="#0058A8" >

       <RelativeLayout
       xmlns:android="http://schemas.android.com/apk/res/android"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       android:background="#0058A8" >



       <EditText
           android:id="@+id/smsnumber"
           android:layout_width="154dp"
           android:layout_height="wrap_content"
           android:layout_alignParentLeft="true"
           android:layout_alignParentTop="true"
           android:layout_marginLeft="14dp"
           android:layout_toLeftOf="@+id/btnRubrica"
           android:ems="10"
           android:inputType="phone" >

       </EditText>

       <Button
           android:id="@+id/btnRubrica"
           android:layout_width="119dp"
           android:layout_height="wrap_content"
           android:layout_alignParentRight="true"
           android:layout_alignParentTop="true"
           android:text="@string/phone_book" />

</RelativeLayout>

       <EditText
           android:id="@+id/smstext"
           android:layout_width="fill_parent"
           android:layout_height="64dp"
           android:inputType="textMultiLine" />

<DatePicker
        android:id="@+id/datePicker1"
        android:layout_width="fill_parent"
        android:layout_height="138dp"
        />

   <TimePicker
       android:id="@+id/timePicker1"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
      />

   <Button
       android:id="@+id/start"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       android:text="@string/start" />

</LinearLayout>

The root of your layout has to be something like this: 布局的根必须是这样的:

<?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:background="#0058A8"
    android:orientation="vertical" >

    <!-- The rest of your layout -->

</LinearLayout>

Notice the android:layout_width="fill_parent" and android:layout_height="fill_parent" properties. 请注意android:layout_width="fill_parent"android:layout_height="fill_parent"属性。

There is no difference in rendering the layout between 2.x and 4.x. 在2.x和4.x之间呈现布局没有区别。 The only difference you saw was that the device with 2.x had smaller resolution than the 4.x one, there fore on the smaller screen the layout was filling up all the space . 您看到的唯一区别是,使用2.x的设备比使用4.x的设备分辨率更低,因此在较小的屏幕上布局占据了所有空间

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

相关问题 致命意外:主要发生在Android 4.x上,而不是Android 2.X - FATAL EXCEPTION: main on Android 4.x but not Android 2.X 在Android 2.x上流式传输文件时出错,在4.x上运行 - Error streaming file on Android 2.x, working on 4.x TabHost视觉样式(2.x和4.x) - TabHost visual style (2.x and 4.x) Android 3.x和4.x中的java.lang.IllegalStateException; 在2.x上正常工作 - java.lang.IllegalStateException in Android 3.x and 4.x ; Works fine on 2.x Android 2.3.6和4.x的NFC检测有所不同 - NFC detection different for Android 2.3.6 and 4.x android 2.x设备上的Android应用程序小部件问题,但在android 4.x设备上可以正常工作吗? - Android app widget issue on android 2.x device But works smoothly on android 4.x device? 膨胀的AlertDialogs在Android 4.X上不可读,而在Android 2.X上看起来很完美 - Inflated AlertDialogs unreadable on Android 4.X while looking perfect on Android 2.X 对于从2.X到4.X的所有Android版本,我如何使用相同的首选项屏幕? - How could I use the same set of preference screens for all Android versions from 2.X to 4.X? “ v17 leanback库”(android电视支持库)可以支持2.x或4.x设备吗? - Can “v17 leanback library”(android tv support library) support 2.x or 4.x device? Android 4.x中的PhoneNumberFormattingTextWatcher - PhoneNumberFormattingTextWatcher in Android 4.x
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM