2010-10-18 160 views
0

Hai Friends, 我开发了一个组合列表视图并在我的htc设备中发布.apk文件的应用程序,设计和对齐一切正常,但问题当我在各种设备如莫罗托罗Droid ,Nexus设备的列表视图的定位出了问题,所以我打算使用的布局文件夹布局,华电国际,布局LDPI和布局MDPI,为我改变了我的清单文件作为支持Android中的多屏幕问题?

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

是不是把android:anyDensity =“true”,我也用dp代替dip。我通过这个网址去了,但仍是无法在这个问题 http://developer.android.com/guide/practices/screens_support.html得到一个清晰的概念。所以朋友们请告诉我(帮助我)在这方面得到清晰的想法,并告诉我有什么错误。这是我的主页xml代码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_marginTop="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> 
+0

问题可能出现在您的布局中。所以我建议你在这里发布它,如果你想获得帮助。 android:anyDensity =“true”意味着你支持所有的屏幕分辨率和android 1.6+。有没有为Android的点:normalScreens = “真正的” 机器人:smallScreens = “真”,如果你有安卓anyDensity = “真”。 – cement 2010-10-18 10:03:53

+0

@ Mr.Cement:u能请通过又来了,我已经发布了乌尔refernce朋友我的主要页面的XML内容。我有一个dobut,如果我使用布局高度fill_parent或wrap_content listview内容隐藏在Morotolo Android设备和Nexus设备,这是我手动更改高度,并将该值在layout-hdpi和layout-ldpi和layout-mdpi。这样对吗???请告诉我 – 2010-10-18 10:10:59

+0

战斗机:你还没有说过你的问题是什么。如果您所说的是“Listviews的对齐错误”,我们无法帮到您。 “出错”一词不是很具体。考虑使用来自DDMS的截图来记录您的问题。此外,如果您的“对齐”属于行的内容,则需要向我们提供行布局XML,而不是活动布局XML。而且,您可能会首先考虑使用'hierarchyviewer'来尝试确定您的布局规则是否按预期行事。 – CommonsWare 2010-10-18 11:34:05

回答

-1

你应该得到的宽度和运行时间

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

装置的高度,使你的布局相应

如果可以,而不是使用XML

编程代码布局这是最好的做法

+0

这不是Android的最佳做法。如果可能的话,你应该用XML设计你的布局,以使代码与布局分开。当然,在某些情况下,您将不得不在运行时更改布局,但在大多数情况下,XML是设置布局的首选方式。 – kcoppock 2010-10-18 15:32:44

+0

所以你试图说,对于不同的设备,我们应该做大量的XML文件?为什么不为布局制作一个方法并在运行时更改它。对于动态工作,你必须在没有XML的情况下工作 – sajjoo 2010-10-19 07:01:05

+1

这个答案是非常不正确的。有一个原因,为什么Android有不同的文件夹名称功能 - 自动检查屏幕的大小和密度,并相应地膨胀正确的布局。是的,kcoppock试图说我们应该根据需要为不同的屏幕密度/大小制作尽可能多的xml文件 - 如果需要的话。 – josephus 2012-06-06 12:10:20

0

是的,Android的工作更好wi th单独的文件夹名称模式,因此也就是用于布局的XML样式表,尽管它使得加载时间稍长一些,而不是使用动态链接的单个XML或直接代码模块从旧的获取屏幕规格的Linux方法动态更新 但是如果你能确定这些设备是否你有问题,也许有glithcy屏幕尺寸报告过程中的一些设备隐藏式触摸按键和/或时钟,无线网络连接图标,数据网络类型图标,等酒吧隐藏在一定程度上许多根据示例,1024x600的程序可能会报告为1024x552或976x600,因为48位状态栏隐藏了屏幕高度和宽度命令,因为antutu使用该方法 因此,在某些类似的系统中,它看起来是1024x600,然后突然实际空间是976x600或1024x552。对于1280×800显示这可能是1216x800或1280x736作为64pixel状态栏是不是一致包含在屏幕大小的报告。这仅仅是一个建议不一定是补救措施,以你的问题,因为前面有人越来越截图表示将有很大的帮助,如果问题是图形不是由于帧格式是根据您的应用程序是如何屈尊来显示列表数据,即不同的问题列表数据是带有填充参数的直接列表视图还是包含在方便的框架中首先