在API 7及更低版本中运行应用程序时缺少自定义ImageView

时间:2012-04-10 15:11:40

标签: android api imageview

我有点好奇的问题。我的Android应用程序在我的手机上运行(Android版本2.3.5,API 9),在我的一些模拟器上(Android版本> = 2.2,API> = 8,在API 8,13,15上测试)而不在其他模拟器上我的模拟器(Android版本< 2.2,API< 8,在API 4,7上测试)。该应用程序不会在API<模拟器上崩溃。 8,但我的一些自定义ImageViews在屏幕上丢失了。否则一切都会正常运作。

我使用了最新版本的工具 lint 来确定我是否使用API​​不支持的任何方法< 8,但我唯一确定的是我使用一种需要API 4的方法,在设置android时没有关于API的错误消息:minSdkVersion = 4,android:targetSdkVersion = 4并将目标构建为4。

我也看了here,因为错误似乎发生在API 7和8之间,但找不到任何东西。我还检查了我的自定义ImageView中的所有方法与开发人员文档,以查看是否需要任何API方法> 7。

有没有人对问题可能有任何其他建议?

修改

这是我的主要xml文件:

<?xml version="1.0" encoding="utf-8"?>

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

<fragment
    android:id="@+id/groundMenuID"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    class="com.foo.bar.someClass"/>

<fragment
    android:id="@+id/topLeftMenuID"
    android:layout_width="@dimen/TopLeftRightMenu_width"
    android:layout_height="@dimen/TopMenu_height"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    class="com.foo.bar.someClass"/>

<fragment
    android:id="@+id/topRightMenuID"
    android:layout_width="@dimen/TopLeftRightMenu_width"
    android:layout_height="@dimen/TopMenu_height"
    android:layout_alignParentTop="true"
    android:layout_alignParentRight="true"
    class="com.foo.bar.someClass"/>

<fragment
    android:id="@+id/leftMenuID"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:layout_alignParentLeft="true"
    android:layout_above="@id/groundMenuID"
    android:layout_below="@id/topLeftMenuID"
    class="com.foo.bar.someClass"/>

<fragment
    android:id="@+id/rightMenuID"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:layout_alignParentRight="true"
    android:layout_above="@id/groundMenuID"
    android:layout_below="@id/topRightMenuID"
    class="com.foo.bar.someClass"/> 

<fragment
    android:id="@+id/topMenuID"
    android:layout_width="fill_parent"
    android:layout_height="@dimen/TopMenu_height"
    android:layout_alignParentTop="true"
    android:layout_toRightOf="@id/topLeftMenuID"
    android:layout_toLeftOf="@id/topRightMenuID"
    class="com.foo.bar.someClass"/>

<com.foo.bar.CustomImageViewLayout
    android:id="@+id/wheelMenuID"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"   
    android:layout_toRightOf="@id/leftMenuID"
    android:layout_toLeftOf="@id/rightMenuID"
    android:layout_below="@id/topMenuID"
    android:layout_above="@id/groundMenuID"/> 

<fragment
    android:id="@+id/figurePassageID"
    android:layout_width="fill_parent"
    android:layout_height="@dimen/figurePassage_height"
    android:layout_above="@id/groundMenuID"
    class="com.foo.bar.someClass"/>


</RelativeLayout>

片段通过标准片段类的onCreateView方法进行膨胀,无论API如何,它们都能正常工作。至于自定义ImageView类......它是很多代码,我不确定我是否要将它粘贴在开放状态(它有点像我的主要知识产权)。我很确定错误不在那里,但我会再次验证它。如果不是,我会尝试粘贴一些代码。

1 个答案:

答案 0 :(得分:0)

尝试将match_parent的所有使用情况更改为fill_parent