视图无法强制转换到android布局中的视图组
我正在为android应用程序设计布局。这是布局的框架。 我尝试的是使用表布局,因为GUI可以分解为表行和表列。 基本上,我想将布局分成两列,如您所见。 下面是xml代码视图无法强制转换到android布局中的视图组,android,android-layout,Android,Android Layout,我正在为android应用程序设计布局。这是布局的框架。 我尝试的是使用表布局,因为GUI可以分解为表行和表列。 基本上,我想将布局分成两列,如您所见。 下面是xml代码 <?xml version="1.0" encoding="utf-8"?> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/tableLayout1" andr
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<!-- 2 columns -->
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dip" >
<View
android:id="@+id/view1"
android:layout_weight="7"
android:layout_width="0dp"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView1"
android:text="Column 1"
android:textAppearance="?android:attr/textAppearanceLarge" />
</View>
<View
android:id="@+id/view2"
android:layout_weight="3"
android:layout_width="0dp"
android:layout_height="wrap_content" >
<Button
android:id="@+id/button1"
android:text="Column 2" />
</View>
</TableRow>
</TableLayout>
我认为这说明我们不能将观点分组。如果不可能,如何处理。我来自网络背景。我想我可以像在html中一样使用视图作为div。您可以对视图进行分组,但需要使用视图组而不是视图 视图组的示例有LinearLayout(用于水平或垂直显示子视图)、RelativeLayout(用于使用相对位置显示子视图)、FrameLayout、TableLayout等。请使用适合您需要的任何视图组 要使某些功能正常工作,请将XML中的两个视图更改为FrameLayouts。并提供按钮和文本视图布局参数(例如,
android:layout\u width=“wrap\u content”
,高度相同),否则运行时会出现另一个错误
Exception raised during rendering: android.view.View cannot be cast to android.view.ViewGroup