微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Android-无法将android.widget.ImageView强制转换为android.view.ViewGroup

试图在模拟比萨表单上获取比萨徽标的背景.

出于某种原因,我不断收到错误消息.

这是布局xml:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".Short_Williams_Assignment3">

<ImageView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:contentDescription="@string/photo"
    android:id="@+id/pizzalogo"
    android:src="@drawable/pizza">
<LinearLayout>
 <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="@string/title_label"
        android:id="@+id/textView"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true" />

    <RadioButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Extra Large"
        android:id="@+id/radioButton4"
        android:checked="false" />

</LinearLayout>
</ImageView>
</FrameLayout>

我不确定为什么会一直收到此错误.我尝试将图像视图包装在框架布局中,但是不起作用.

感谢您提供的任何帮助!

解决方法:

问题是< / ImageView>.由于ImageView无法承载视图,因此无法将其环绕.摆脱< / ImageView>并从

<ImageView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:contentDescription="@string/photo"
    android:id="@+id/pizzalogo"
    android:src="@drawable/pizza">

<ImageView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:contentDescription="@string/photo"
    android:id="@+id/pizzalogo"
    android:src="@drawable/pizza" />

/>将关闭ImageView的标签

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐