Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/193.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android-Android.widget.ImageView无法强制转换为Android.view.ViewGroup_Android_Imageview_Android Framelayout - Fatal编程技术网

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

Android-Android.widget.ImageView无法强制转换为Android.view.ViewGroup,android,imageview,android-framelayout,Android,Imageview,Android Framelayout,试图在模拟比萨饼表单上获得比萨饼徽标的背景 由于某种原因,我不断地出错 以下是布局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:pad

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

由于某种原因,我不断地出错

以下是布局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
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:contentDescription="@string/photo"
    android:id="@+id/pizzaLogo"
    android:src="@drawable/pizza">



/>
将关闭
ImageView
的标记

您不能在ImageView标记内放置任何视图

如果你想设置这个标志,试着像这样使用你的线性布局的背景

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/pizza">
    <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>

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/pizza">
    <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>