开发者

xml layout not supporting all screens

My xml layout doesnt support all screen sizes , below is the xml layout. please help.

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/scroll" android:layout_width="fill_parent" android:layout_height="fill_parent"  android:fillViewport="true">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:paddingTop="10px"
                android:layout_width="fill_parent" 
                android:layout_height="fill_parent"
                android:background="@drawable/formbg">


 <LinearLayout android:id="@+id/linearLayout1" 
        android:layout_width="fill_parent" android:layout_height="wrap_content"
        android:orientation="horizontal" android:layout_alignParentTop="true" 
        android:layout_alignParentLeft="true" android:layout_alignParentRight="true">

    <TextView android:id="@+id/label" 
              android:layout_width="120px" 
              android:layout_height="wrap_content" 
              android:text="Question Title" 
              android:textStyle="bold"
              android:textSize="12sp" 
              android:textColor="#000000" 
    android:paddingLeft="5px"
    android:paddingRight="5px"
    android:paddingTop="10px"
    android:paddingBottom="10px"
              />

    <EditText android:id="@+id/entry" 
              android:layout_width="match_parent" 
              android:layout_height="wrap_content" 
              android:textColor="#000000"   
    android:paddingLeft="10px"
    android:paddingRight="5px"
    android:paddingTop="10px"
    android:paddingBottom="10px"
              />

 </LinearLayout>


   <LinearLayout android:id="@+id/linearLayout2"
        android:layout_below="@id/linearLayout1" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:orientation="horizontal"
        android:layout_alignParentLeft="true" android:layout_alignParentRight="true"  android:paddingRight="0px" > 

   <TextView android:id="@+id/pass" 
              android:layout_width="120px" 
              android:layout_height="wrap_content" 
              android:text="Type Description" 
              android:textStyle="bold"
              android:textSize="12sp" 
              android:textColor="#000000" 
    android:paddingLeft="5px"
    android:paddingRight="5px"
    android:paddingTop="10px"
    android:paddingBottom="10px"
    />

    <EditText android:id="@+id/passentry" 
              android:layout_width="match_parent" 
              android:layout_height="100px" 
              android:textColor="#000000"   
    android:paddingLeft="10px"
    android:paddingRight="5px"
    android:paddingTop="10px"
    android:paddingBottom="10px"
              />

   </LinearLayout>


   <LinearLayout android:id="@+id/linearLayout3"
        android:layout_below="@id/linearLayout2" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:orientation="horizontal"
        android:layout_alignParentLeft="true" android:layout_alignParentRight="true">

    <TextView android:id="@+id/labelbounty" 
              android:layout_width="120px" 
              android:layout_height="wrap_content" 
              android:text="Enter Amount  $" 
              android:textStyle="bold"
              android:textSize="12sp" 
              android:textColor="#000000" 
    android:paddingLeft="5px"
    android:paddingRight="5px"
    android:paddingTop="10px"
    android:paddingBottom="10px" 
               />

     <EditText android:id="@+id/bounty" 
              android:numeric="decimal"
              android:layout_width="match_parent" 
              android:layout_height="wrap_content" 
              android:textColor="#000000" 
    android:paddingLeft="10px"
    android:paddingRight="5px"
    android:paddingTop="10px"
    android:paddingBottom="10px"
               />          


   </LinearLayout>


    <LinearLayout android:id="@+id/linearLayout4"
        android:layout_below="@id/linearLayout3" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:orientation="horizontal"
        android:layout_alignParentLeft="true" android:layout_alignParentRight="true">



   <TextView android:id="@+id/duedatelabel" 
              android:layout_width="120px" 
              android:layout_height="wrap_content" 
              android:text="Due Date" 
              android:textStyle="bold"
              android:textSize="12sp" 
              android:textColor="#000000" 
    android:paddingLeft="10px"
    android:paddingRight="5px"
    android:paddingTop="10px"
    android:paddingBottom="10px" />

  <Button android:id="@+id/pickDate"
        android:layout_width="matc开发者_运维百科h_parent"
        android:layout_height="wrap_content"
        android:textColor="#000000" 
   android:paddingLeft="10px"
    android:paddingRight="5px"
    android:paddingTop="10px"
    android:paddingBottom="10px"
        android:text="Select Due Date"/>

   </LinearLayout>

    <LinearLayout android:id="@+id/linearLayout5"
        android:layout_below="@id/linearLayout4" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:orientation="horizontal"
        android:layout_alignParentLeft="true" android:layout_alignParentRight="true">


     <TextView android:id="@+id/labelprimary" 
              android:layout_width="120px" 
              android:layout_height="wrap_content" 
              android:text="Category" 
              android:textStyle="bold"
              android:textSize="12sp" 
              android:textColor="#000000" 
    android:paddingLeft="10px"
    android:paddingRight="5px"
    android:paddingTop="10px"
    android:paddingBottom="10px"
               />

    <Spinner 
        android:id="@+id/primarycategory"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:prompt="@string/planet_prompt"
        android:textColor="#000000"
        android:paddingLeft="15px"
    android:paddingRight="5px"
    android:paddingTop="10px"
    android:paddingBottom="10px" 
    /> 
    </LinearLayout>


    <LinearLayout android:id="@+id/linearLayout6"
        android:layout_below="@id/linearLayout5" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:orientation="horizontal"
        android:layout_alignParentLeft="true" android:layout_alignParentRight="true">

     <TextView android:id="@+id/labelsecondary" 
              android:layout_width="120px" 
              android:layout_height="wrap_content" 
              android:text="Sub Category" 
              android:textStyle="bold"
              android:textSize="12sp" 
              android:textColor="#000000" 
     android:paddingLeft="10px"
    android:paddingRight="5px"
    android:paddingTop="10px"
    android:paddingBottom="10px"
               />

    <Spinner 
        android:id="@+id/secondarycategory"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:prompt="@string/secondary_category"
        android:textColor="#000000" 
    android:paddingLeft="15px"
    android:paddingRight="5px"
    android:paddingTop="10px"
    android:paddingBottom="10px" 
    />              
    </LinearLayout>


    <LinearLayout android:id="@+id/linearLayout7"
        android:layout_below="@id/linearLayout6" android:layout_width="wrap_content"
        android:padding="10px"
        android:layout_height="wrap_content" android:orientation="horizontal"
        android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:paddingRight="10px" android:paddingLeft="10px">

    <Button android:id="@+id/button1" 
    android:layout_width="fill_parent" 
    android:layout_height="65px" 
    android:background="@drawable/add_attachment"
    >

    </Button>

    </LinearLayout>




     <LinearLayout android:id="@+id/linearLayout8"
        android:layout_below="@id/linearLayout7" android:layout_width="wrap_content"
        android:padding="10px"
        android:layout_height="wrap_content" android:orientation="horizontal"
        android:layout_alignParentLeft="true" android:layout_alignParentRight="true"  android:paddingRight="10px" android:paddingLeft="10px">


    <Button android:id="@+id/askNow" 
            android:layout_width="fill_parent" 
            android:layout_height="65px" 
            android:layout_alignParentRight="true"
            android:background="@drawable/postquestions"/>

    </LinearLayout>




    <SlidingDrawer android:id="@+id/SlidingDrawer" android:handle="@+id/slideHandleButton" android:content="@+id/contentLayout" android:topOffset="50dip" android:layout_width="600px" android:layout_height="700px">
        <Button android:layout_width="wrap_content" android:layout_height="65px" android:id="@+id/slideHandleButton" android:background="@drawable/bottom_bar"></Button>
        <LinearLayout android:background="@drawable/slider_bg" android:id="@+id/contentLayout"  android:layout_width="match_parent" android:layout_height="match_parent"
                        android:orientation="vertical" android:gravity="center" 
                        >
        <Button android:id="@+id/asknew" android:layout_width="wrap_content" android:layout_height="65px" android:background="@drawable/ask_new_question"></Button>
        <Button android:id="@+id/logout" android:layout_width="wrap_content" android:layout_height="65px" android:background="@drawable/logout_big"></Button>
        </LinearLayout>
    </SlidingDrawer>


    <android.view.SurfaceView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/preview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
    </android.view.SurfaceView>
</RelativeLayout>
</ScrollView>


It would help if you posted images of which screens it doesn't support and why. But a brief look at your layout leads me to this suggestion: Don't use absolute pixel measurements. Use "dp" instead of "px". Also, read the guide topic on supporting multiple screens.


You should probably change all the places where you use px to dp.

WHen you use dp, which is short for "density independant pixels", your layout should support multiple screens.


Use dip which density independent pixels instead of px which are pixels

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜