1 android android-linearlayout
我是android的新手.现在我收到了嵌套重量不良表现的警告.我的第一个屏幕上只有一个图像和三个按钮.PLs给了我一些想法.
<LinearLayout 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:background="@color/backgroundColor"
android:orientation="vertical"
android:gravity="center_horizontal"
android:weightSum="10"
>
<ImageView
android:layout_weight="4"
android:id="@+id/imageLogo"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:contentDescription="@string/Img"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:src="@drawable/home_screen_logo" />
<LinearLayout
android:layout_weight="6"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:orientation="vertical"
android:gravity="center_horizontal"
>
<LinearLayout android:layout_height="0dp" android:layout_width="fill_parent"
android:layout_weight="1"
android:id="@+id/temp"></LinearLayout>
<ImageButton
android:id="@+id/btnLogin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/login"
android:contentDescription="@string/Img"
android:layout_weight="1"
/>
<LinearLayout android:layout_height="0dp" android:layout_width="fill_parent"
android:layout_weight="1"></LinearLayout>
<ImageButton
android:id="@+id/btnFbLogin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/btnfb"
android:contentDescription="@string/Img"
/>
<LinearLayout android:layout_height="0dp" android:layout_width="fill_parent"
android:layout_weight="1"></LinearLayout>
<ImageButton
android:id="@+id/btnRegister"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/btnregister"
android:contentDescription="@string/Img"/>
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
提前致谢
嵌套权重对性能不利,因为:
布局权重需要两次测量窗口小部件.当具有非零权重的LinearLayout嵌套在具有非零权重的另一个LinearLayout内时,则测量数量呈指数增长.
RelativeLayouts在不使用特定dpi值的情况下,根据其他视图的位置使用和调整视图总是更好.
| 归档时间: |
|
| 查看次数: |
5440 次 |
| 最近记录: |