2010-09-24 1 views
3

alt textcomment mettre en page le soutien pour divers écran dans Android?

alt text

Je développe vue galerie à l'aide gridview, dans le petit écran ma conception de mise en page fixe très bien, mais grand écran n'a pas ma conception, en grand écran ont des espaces ci-dessous « charge plus image » bouton référer fig2, comment puis-je résoudre ce problème, mon fichier Manifest a ajouté des lignes de soutien différents écran, s'il vous plaît donner quelques exemples de code pour moi ..

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

et mon code xml

<?xml version="1.0" encoding="utf-8"?> 
<merge android:layout_width="wrap_content" android:layout_height="340dp" xmlns:android="http://schemas.android.com/apk/res/android"> 
<LinearLayout android:id="@+id/LinearLayout01" 
android:layout_width="fill_parent" 
android:layout_height="335dp" android:orientation="vertical" 
android:background="@color/black"> 


<GridView 
        android:id="@+id/jr_lookbook_grid" android:layout_width="fill_parent" 
        android:layout_height="335dp" android:numColumns="4" 
        android:verticalSpacing="10dp" android:horizontalSpacing="10dp" 
        android:columnWidth="90dp" android:stretchMode="columnWidth" 
        android:adjustViewBounds="true" 
        android:background="@drawable/shape" 
        android:gravity="center" android:layout_weight="1"/> 
</LinearLayout> 
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/LinearLayout0209_img" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:gravity="center" 
    android:paddingTop="311dp"> 
     <Button android:id="@+id/click" 
       android:background="#AA000000" 
        android:text="Load More Pictures..." 
        android:textColor="@color/white"     
        android:layout_width="fill_parent" android:layout_height="30dp"/> 
    </LinearLayout> 
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/LinearLayout02_img" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:layout_gravity="center" 
    android:layout_alignParentBottom="true" 
    android:background="@color/black" 
       android:layout_alignParentLeft="true"> 
    <WebView 
     android:id="@+id/webview" 

     android:layout_width="fill_parent" 

     android:layout_height="fill_parent"   
     android:scrollbars="none" /> 
    <ImageView android:id="@+id/ImageView01" 
    android:layout_gravity="center_horizontal" 
    android:scaleType="centerInside" 
    android:layout_width="wrap_content" 
    android:layout_height="fill_parent" 
    android:adjustViewBounds="true"> 
</ImageView> 
    </LinearLayout> 
    <LinearLayout android:id="@+id/LinearLayout02"  android:background="#AA000000" 
     android:layout_width="400px" 
     android:layout_height="50dp" 
     android:layout_gravity="bottom"> 
<Button 
    android:id="@+id/back 
       android:layout_height="wrap_content" 
       android:background="@drawable/back1" 
       android:layout_alignParentRight="true" 
       android:layout_marginLeft="10dp"/
       <Button 
        android:background="@drawable/forward5" 
       android:id="@+id/next" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:gravity="center" 
       android:layout_alignParentRight="true" 
       android:layout_marginLeft="150dp"/> 
        <Button 
        android:background="@drawable/menushare" 
       android:id="@+id/photoshare" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:gravity="center" 
       android:layout_alignParentRight="true" 
       android:layout_marginLeft="20dip" /> 
</LinearLayout> 
</merge> 

Merci Tous

Répondre

3

Vous devez écrire du code XML pour grand écran. Je pense que vous gardez votre fichier xml dans le dossier res/layout. si c'est le cas, vous pouvez garder trois dossiers pour différencier les différents écrans comme res/layout-small, res/layout, res/layout-long. Dans ces trois dossiers, vous pouvez définir différents alignements pour différents types d'écran. Pour écran moyen, gardez votre code xml dans la mise en page, et pour les petits écrans - le conserver dans la mise en page et à petites etc., et mettre

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

ces lignes dans votre AndroidManifest.xml

+0

Thanx. s'est avéré utile pour moi. – Freelancer