Android嵌套布局

min*_*ini 7 android relativelayout android-layout nestedlayout

我是Android布局的新手,请告诉我在使用嵌套布局而不是使用下面的布局时,应用程序的性能如何,布局上面,布局正确,布局左侧组件的相对布局属性.

例如:

<RelativeLayout>
    <scrollView>
       <RelativeLayout>
          <LinearLayout> Header<LinearLayout>
           <TextView/>  <TextView/>
           <TableLayout>
                   <TableRow><ImageView/> <TextView> <Spinner><TableRow>
                   <TableRow><ImageView/> <TextView> <Spinner><TableRow>
                   <TableRow><ImageView/> <TextView> <Spinner><TableRow>
                   <TableRow><ImageView/> <TextView> <Spinner><TableRow>
          </TableLayout>

          <TextView>
          <TableLayout>
                 <TableRow>
                    <LinearLayout> <ImageView><TextView></LinearLayout> 
                    <EditText>
                 </TableRow>
                 <TableRow>
                    <LinearLayout> <ImageView><TextView></LinearLayout>
                    <EditText>
                </TableRow>
                <TableRow>
                   <TextView> 
                   < Spinner>
                </TableRow>
                <TableRow><TextView> <Spinner></TableRow>
          </TableLayout>

           <TableLayouts>---</TableLayout>

          <LinearLayout> footer</LinearLayout>
</RelativeLayout>
<ScrollView>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

谢谢和问候Yamini

War*_*zit 10

一些布局只能通过进行一定程度的嵌套来实现.但是你应该避免使用太多嵌套的LinearLayouts,更重要的是不要使用权重嵌套LinearLayouts.您可以在官方文档中阅读有关优化布局的更多信息.

我个人使用LinearLayouts来处理简单的事情,并在布局变得更复杂时开始使用RelativeLayout.没有一个答案,因为这是一个偏好的问题.