How to occupy an layout 75% of the screen and another 25% -----
Steps
Use Linear Layouts-------------
Current scenerio
1: A main Linear layout contains two child linear layouts.
2: We have a Main Linear layout(Orientation ="horizontal") and two child as "linTop" and "linBottom".
What we want??
Occupy 75% of the screen using "linTop"
occupy 25% of the screen using "linBottom".
For that use the following
Step1: In our Main linear layout,use attribute "Weight_sum =3"
step2: in our "linTop" layout ,use "Weight=2" ,width =0dip,Height=match_parent.
step3: In our "linBottom" layout,use weight =1,width =0dip,height=match_parent.
sample xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/relMain"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:orientation="vertical"
android:weightSum="5" >
<LinearLayout
android:id="@+id/linTop"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="3"
android:orientation="vertical" >
<SurfaceView
android:id="@+id/surCamera"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginBottom="20dip"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:layout_marginTop="20dip" />
</LinearLayout>
<LinearLayout
android:id="@+id/linBottom"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:layout_weight="2"
android:orientation="vertical" >
<Button
android:id="@+id/btnCapture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Capture" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
0 comments: