I am developing an Android application for the SPen . I am having some trouble getting the bottom menu within a LinearLayout to show up below the SCanvasView within a ReletiveLayout. It must be an attribute I set within canvas_container since I can show the bottom menu when I set the height of the canvas_container to a specific size.
The attribute I am giving the bottom menu is android:layout_alignParentBottom="true".
To simplify the layout: I just want a menu bar on top and the bottom (both containing ImageViews) and the space in between them to be filled with a SCanvasView and an ImageView (both the same size).
Here is some simplified code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/menu1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:gravity="left"
android:id="@+id/iv_top1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/topimage1"
android:layout_weight=".25"/>
<ImageView
android:gravity="left"
android:id="@+id/iv_top2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/topimage2"
android:layout_weight=".25"/>
</LinearLayout>
<LinearLayout
android:id="@+id/menu4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightSum="1.0"
android:layout_alignParentBottom="true">
<ImageView
android:gravity="left"
android:id="@+id/iv_bottom1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/bottomimage1"
android:layout_weight=".25"/>
<ImageView
android:gravity="left"
android:id="@+id/iv_bottom1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/bottomimage1"
android:layout_weight=".25"/>
</LinearLayout>
<RelativeLayout
android:id="@+id/canvas_container"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.samsung.spensdk.SCanvasView
android:id="@+id/canvas_view"
android:layout_width="wrap_content"
android:layout_height="match_parent" />
<ImageView
android:id="@+id/imgView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"/>
</RelativeLayout>
</RelativeLayout>
I think I misunderstood but a LinearLayout
with vertical orientation
would probably be better in this situation. This way you can use weightSum
. Set the weightSum
to 4 then the weight of each LinearLayout
for the menus to 1 and the RelativeLayout
weight to 2 or adjust that according to what you want.
Also note that RelativeLayout
doesn't have an orientation
property. And when using weights
and weightSum
you want your width
for each View
to be 0 dp
for horizontal orientation
and height
set to 0dp
for vertical orientation