Reputation: 179
I'm struggling to come to grips with android layouts, firstly can anyone point me to a good basic tutorial on working with the layouts on screen. I understand the concepts when i read the google layout dev ref, but come to practice and I don't quite get it.
I have the below layout that I am trying to replicate in an Android screen, I believe I need to nest different layouts within others, but I can't quite get what I have to look like this: http://screencast.com/t/GFw7OSzvbmX
Any suggestions on code out there similar and also the tutorials to get me going would be great thx
Upvotes: 1
Views: 72
Reputation: 693
(Black - LinearLayout Vertical ) (Red - LinearLayout Horizontal ) (Green - ImageView ) (Yellow - TextView ) (Brown - Button )
Visualize like this first . Then write your xml .
Upvotes: 2
Reputation: 24848
Use TextView,Button,ImageView as child and use LinearLayout as parent with weight which handle area allocation child content :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.40">
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:scaleType="fitXY"
android:src="@drawable/ic_launcher"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="textview"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="textview"
android:layout_marginTop="5dp"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.60"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="textview"
android:layout_marginTop="5dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="textview"
android:layout_marginTop="5dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="textview"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="button"/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="textview"
android:layout_marginTop="5dp"/>
</LinearLayout>
</LinearLayout>
Upvotes: 1