FrameLayout layout_frame=(LinearLayout)findViewById(R.id.layout_frame);FrameLayout 和 LinearLayout ,你编译都通不过

解决方案 »

  1.   

    编译能通过
    <LinearLayout android:id="@+id/layout_linear"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:scaleType="center"
            android:background="@color/cl_beige" >
            <ImageView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scaleType="fitCenter"
                android:id="@+id/imageview_background" />
    </LinearLayout><FrameLayout android:id="@+id/layout_frame"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:scaleType="center"
            android:background="@color/cl_beige" >
            <ImageView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scaleType="fitCenter"
                android:id="@+id/imageview_background" />
    </FrameLayout>
    (1)
    LinearLayout layout_linear=(LinearLayout)findViewById(R.id.layout_linear);
    layout_linear.setLayoutParams(new LinearLayout.LayoutParams(200,200);(2)
    FrameLayout layout_frame=(FrameLayout )findViewById(R.id.layout_frame);
    layout_frame.setLayoutParams(new LinearLayout.LayoutParams(200,200);为什么运行(2)程序会错误自动退出,而运行(1)程序却正常使用?
      

  2.   

    (2)
    FrameLayout layout_frame=(FrameLayout )findViewById(R.id.layout_frame);
    layout_frame.setLayoutParams(new FrameLayout .LayoutParams(200,200);