2013-02-28 137 views
-1

Im寻找解决我的布局在Android上的多屏幕尺寸的最佳途径。我有一个伟大的应用程序,几乎是准备发射。然而我的合作伙伴之一,试图在一个三星平板和图标和一些功能太小Android中的多屏幕支持

所以我在想什么让我的屏幕分辨率改变大小还是有一个更简单的方法?

这是我的布局代码任何建议都会有帮助吗?


<?xml version="1.0" encoding="utf-8"?> 
<merge xmlns:tools="http://schemas.android.com/tools" 
xmlns:pj="http://schemas.android.com/apk/res/com.example.waysecure" 
xmlns:bm="com.example.waysecure" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical"  xmlns:android="http://schemas.android.com/apk/res/android"> 
<Button 
    android:id="@+id/button_pannic" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/pannic" 
    android:visibility="visible" /> 
<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_gravity="bottom" 
    android:layout_marginTop="50dp" > 
    <WebView 
     android:id="@+id/webView1" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 

    <FrameLayout 
     android:id="@+id/Fofo" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" > 
    </FrameLayout> 
    </RelativeLayout> 
<SlidingDrawer 
android:id="@+id/sg_below" 
android:layout_width="match_parent" 
android:layout_height="275dp" 
android:layout_gravity="bottom" 
android:layout_marginTop="200dp" 
android:content="@+id/content" 
android:handle="@+id/handle" > 
<Button android:layout_width="match_parent" android:layout_height="60dp" android:id="@+id/handle" android:background="@drawable/tray_handle_normal" /> 
<RelativeLayout 
    android:id="@+id/content2" 
    android:layout_width="wrap_content" 
    android:layout_height="282dp" 
    android:background="#aa000000" > 
     </RelativeLayout><TabHost android:id="@+id/content" android:layout_width="match_parent" android:layout_height="match_parent"> 
    <FrameLayout 
      android:id="@android:id/tabcontent" 
      android:layout_width="match_parent" 
      android:layout_height="fill_parent" 
      android:layout_gravity="bottom" 
      android:background="#aa000000" > 
<LinearLayout android:id="@+id/tab1" android:layout_width="match_parent" android:layout_height="match_parent"> 


      </LinearLayout> 
       <GridView 
        android:id="@+id/tab2" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:layout_gravity="bottom" 
        android:columnWidth="90dp" 
        android:gravity="center" 
        android:horizontalSpacing="1dp" 
        android:numColumns="auto_fit" 
        android:stretchMode="columnWidth" 
        android:verticalSpacing="1dp" > 
      </GridView> <LinearLayout android:id="@+id/tab3" android:layout_width="match_parent" android:layout_height="match_parent"> 
        <com.carouseldemo.controls.Carousel android:id="@+id/carousel2" android:layout_width="match_parent" android:layout_height="match_parent" android:animationDuration="200" pj:Items="@array/entries" pj:Names="@array/names" pj:SelectedItem="0" pj:UseReflection="true"> 
       </com.carouseldemo.controls.Carousel> 
      </LinearLayout> 
     </FrameLayout> 
    <TabWidget 
      android:id="@android:id/tabs" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="top" > 
     </TabWidget> 
    </TabHost> 
</SlidingDrawer> 
</merge> 
+0

@Jhono詹姆斯根据大小将适当的图像中的所有文件夹绘制。 – 2013-02-28 07:07:19

回答

1

你要做的唯一事情是在你的manifest和下方添加<support-screens><support-screens>:用于创建一致的布局

<supports-screens android:resizeable=["true"| "false"] 
       android:smallScreens=["true" | "false"] 
       android:normalScreens=["true" | "false"] 
       android:largeScreens=["true" | "false"] 
       android:xlargeScreens=["true" | "false"] 
       android:anyDensity=["true" | "false"] 
       android:compatibleWidthLimitDp="integer" 
       android:largestWidthLimitDp="integer"/> 

提示:

  1. 不要硬 - 编码任何layout参数,例如width,height等。
  2. 不使用“px”。用“sp”的文本大小和“dp”为layout-widthlayout-height
  3. 利用RelativeLayoutLinearLayout和不使用AbsoluteLayout,因为它已经过时了。
  4. 使用ScrollView只要需要layouts,因为它支持singleView。

欲了解更多信息,请查阅Support Multiple Screens的Android Developer文档。

4

您需要在res文件夹中为不同的屏幕添加额外的布局。

如果你想7 inch在res名,创建布局文件夹layout-sw720dp

对于10 inch创建layout-xlarge

layout文件夹中复制所有文件和粘贴文件,并调整大小。

转换并测试所有屏幕。

请参考链接了解更多屏幕的

http://developer.android.com/guide/practices/screens_support.html

1

我配置了这种方式。对我而言,这是一种打击和试用的方法。当我开发我的first android application时,同样的问题发生在我身上,但最终我钉上了它。为了支持每个屏幕的分辨率完美,在全屏图像的情况下,使不同分辨率的4张图片:

hdpi: 480*800 
ldpi: 320*460 
mdpi:720*960 
xhdpi: 800*1280 

如果您的应用支持两个方向,然后做出不同的布局为横向模式,并与同一个地方它在这个link可以找到布局土地名称和相关信息。

+0

感谢这有所帮助 – JonoJames 2013-03-15 02:28:09

1

你必须创建layout_size文件夹在不同尺寸的屏幕res文件夹

创建不同势的XML文件。

0

请reffer this..it可帮助you..fend device screens and resolutions