Android : Best way to do the same than you can do with nested linearlayouts

on Tuesday, September 2, 2014


I have to create a windows8 like screen. I create it easily using nested linearlayouts. I know from a performance point of view it is not a good idea be having nested linearlayouts, so I want to ask you which other way I can do that, which scale well between portrait and landscape and have a better performance. Even because really each textview in the next xml code will be really implemented with another linearlayout, because it have to include text and icons. Sadly I am new in stackoverflow so I can publish images



<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg1_blurred"
android:gravity="center"
tools:context="com.lm2a.w8opt.MainActivity" >

<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="300dp"
android:layout_height="200dp"
android:orientation="vertical"
android:weightSum="5" >

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:orientation="horizontal"
android:weightSum="5" >

<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="1dp"
android:layout_weight="1"
android:textColor="@color/txt_color_white"
android:textSize="@dimen/text_big"
android:background="@color/square_color_red"
android:padding="10dp"
android:text="T" />

<TextView
android:id="@+id/textView2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="1dp"
android:layout_weight="4"
android:background="#00000000"
android:text="W" />
</LinearLayout>

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="3"
android:orientation="horizontal"
android:weightSum="5" >

<TextView
android:id="@+id/textView3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="1dp"
android:layout_weight="1"
android:background="@color/square_color_yellow"
android:text="X" />

<TextView
android:id="@+id/textView4"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="1dp"
android:layout_weight="2"
android:background="@color/square_color_blue"
android:text="Y" />

<TextView
android:id="@+id/textView5"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="1dp"
android:layout_weight="2"
android:background="@color/square_color_green"
android:text="Z" />
</LinearLayout>
</LinearLayout>

</LinearLayout>

0 comments:

Post a Comment