开发者

Problem in Supporting Multiple Screens in Android?

Hai Friends, I have developed an application which en-composes list views and posted that .apk file in my htc device, the design and alignment everything works fine,but the problem When i am testing in various devices such as Morotolo Droid,Nexus Devices the alignment of Listviews goes wrong, so i planned to use the Layout folder as layout-hdpi,layout-ldpi, and layout-mdpi, for that i changed my manifest file as

<supports-screens android:largeScreens="true" 
        android:normalScreens="true" android:smallScreens="true"
        android:anyDensity="true" /> 

Is it right putting android:anyDensity="true",also i used dp instead of dip. I went through this url, but still am not able to get a clear idea in this http://developer.android.com/guide/practices/screens_support.html. so friends pls tell me(help me) to get clear idea in this and tell what mistakes i have doing. This is my main page xml code frnds.

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost" android:layout_width="fill_parent"
    android:layout_height="wrap_content">

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@drawable/background_retinav2">   

     <LinearLayout android:layout_gravity="center" android:foregroundGravity="bottom" android:background="@color/white" android:id="@+id/rl_1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal">
        <ImageView  android:paddingTop="3dp" android:id="@+id/starthideimage" android:layout_width="30dp" android:layout_height="35dp" android:src="@drawable/newback" />
        <HorizontalScrollView  android:paddingTop="8dp" android:id="@+id/gv"
        android:layout_width="wrap_content" android:layout_margi开发者_Python百科nTop="0dp"
        android:layout_height="wrap_content" android:background="#ffffff"
        android:scrollbars="none" android:layout_weight="1" android:foregroundGravity="bottom">
        <LinearLayout android:id="@+id/san_tag" android:layout_width="wrap_content" android:layout_height="wrap_content">
        </LinearLayout>
    </HorizontalScrollView>
    <ImageView  android:paddingTop="3dp" android:id="@+id/Endhideimage" android:layout_width="30dp" android:layout_height="35dp" android:src="@drawable/newforward" />
    </LinearLayout>

    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical" android:id="@android:id/tabcontent"  
        android:layout_width="fill_parent"  android:layout_height="fill_parent">



         <ListView android:id="@+id/content_movies" android:cacheColorHint="@color/cachecolor" 
           android:layout_weight="1" android:scrollbars="vertical"
           android:layout_width="fill_parent" android:layout_height="420dp"/>

        </FrameLayout>   
 </LinearLayout>

<TabWidget
    android:id="@android:id/tabs"
    android:gravity="bottom"
    android:layout_gravity="bottom"
    android:listSelector="@color/gray"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" /> 

</TabHost>


Yes Android does work better with the separate folder name schema and thusly the XML style sheets for layout there within although it makes for a little longer load time rather than using a dynamically linked single XML or direct code module dynamically updated from that old Linux method of acquiring screen specs However if you could determine whether the devices you have problems with perhaps have a glithcy screen size report process as some devices hide system touch buttons and/or the bar with the clock, WiFi icon, data network type icon, etc hidden to some extent to many programs as per example a 1024x600 may report as 1024x552 or 976x600 because the 48pixel status bar is hidden from get screen height and width commands as antutu uses that approach Thus in some heirachy systems it sees 1024x600 then suddenly actual space is 976x600 or 1024x552. For 1280x800 displays this can be 1216x800 or 1280x736 as the 64pixel status bar is not unanimously included in screen size reporting. This is merely a suggestion not necessarily a remedy to your problem as said earlier by someone getting screenshots will help a lot if the problem is graphical not due to frame formatting which is different matter depending on how your app is deigned to display the list data ie whether the list data is direct list view with padding params or contained within a convenient frame first


You should get width and height of device on run time

Display display = getWindowManager().getDefaultDisplay();
screenWidth = display.getWidth();
screenHeight = display.getHeight();

And the make your layout accordingly

If you can code your layout programatically instead of using xml

It'd be best practice

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜