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

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

这是布局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不能承载 View ,因此无法将其环绕。摆脱</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的标签

关于Android-无法将android.widget.ImageView强制转换为android.view.ViewGroup,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33396568/

10-12 01:23
查看更多