Android 在API 7及以下版本中运行应用程序时缺少自定义图像视图
我有一个奇怪的问题。我的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的模拟器上运行,但我的一些自定义图像视图在屏幕上丢失了。否则一切都会正常运转 我使用了工具lint的最新版本来确定我是否使用了API<8不支持的任何方法,但我唯一确定的是,我使用了一种需要API 4的方法,在将android:minSdkVersion=4、android:targetSdkVersion=4和build target设置为4时,没有关于API的错误消息 由于错误似乎发生在API 7和8之间的某个地方,我也进行了查找,但没有找到任何内容。我还根据开发人员文档检查了自定义ImageView中的所有方法,以查看是否有任何方法需要API>7 有没有人对可能出现的问题有其他建议 编辑: 这是我的主要xml文件:Android 在API 7及以下版本中运行应用程序时缺少自定义图像视图,android,api,imageview,Android,Api,Imageview,我有一个奇怪的问题。我的Android应用程序在我的手机上运行Android版本2.3.5,API 9,在我的一些模拟器上运行Android版本>=2.2,API>=8,在API 8、13、15上测试,而在我的其他模拟器上运行Android版本
<?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类。。。它有很多代码,我不确定我是否想把它粘贴到公开的地方,这是我的主要知识产权。我很确定错误不在那里,但我会再次验证它。如果没有,我将尝试粘贴一些代码。尝试更改“匹配父项”的所有用法以填充父项 如果您发布一些代码,我们可能会帮助您:出现问题的xml视图和您的自定义图像视图。@YuviDroid:我已经用我的xml文件更新了。片段工作正常,我猜错误可能在CustomImageViewLayout中,它是一个扩展的RelativeLayout类,或者在CustomImageView中。很好的建议,谢谢。不幸的是,我已经做了那些没有效果的更改。编辑:此建议是由于将填充父项更改为匹配父项,从API 7更改为8。