Android的嵌套布局 [英] Android nested layouts

查看:150
本文介绍了Android的嵌套布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新到Android的布局,如何应用程序的性能时使用嵌套布局,而不是使用下面的布局,布局上面,布局对的,因为成分相对布局的布局留下的属性,请告诉我。

I am new to android layouts, Could please tell me how the performance of application when using nested layouts instead of using layout below, layout above, layout right, layout left attributes of relative layout for components.

有关例如:

<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>

感谢和放大器;问候
雅米妮(Yamini)

Thanks & Regards Yamini

推荐答案

好一些布局,只能通过做嵌套的某些层面上进行。但是,你应该避免过多的嵌套LinearLayouts更重要NEVER巢LinearLayouts配重块。你可以阅读更多一点关于href=\"http://developer.android.com/training/improving-layouts/optimizing-layout.html\" rel=\"nofollow\">官方文档的

Well some layouts can only be made by doing some level of nesting. But you should avoid having too many nested LinearLayouts and even more important NEVER nest LinearLayouts with weights. You can read a little more about optimizing layouts in the official docs.

我个人使用的简单的东西LinearLayouts并开始使用的RelativeLayout时的布局变得更加复杂。有没有一个答案,因为它是prefference的问题。

Personally I use LinearLayouts for simple stuff and start using RelativeLayout when the layout gets more complex. There is no one answer as it is a matter of prefference.

这篇关于Android的嵌套布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆