簡體   English   中英

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

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

我在項目可視化方面遇到了一些麻煩。 在android 2.x xml上填充屏幕,但在4.x中它們覆蓋約50%的屏幕,其余50%則全是黑色。 我認為使用fill_parent和wrap_content可以幫助我! 我如何使其標准化? 這是來源

     <?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>

布局的根必須是這樣的:

<?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>

請注意android:layout_width="fill_parent"android:layout_height="fill_parent"屬性。

在2.x和4.x之間呈現布局沒有區別。 您看到的唯一區別是,使用2.x的設備比使用4.x的設備分辨率更低,因此在較小的屏幕上布局占據了所有空間

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM