I have created my own drawable object, which I am setting to be the background of an image button. (described here)
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#A7BF1D"/> </shape>
I want these to be spaced equally vertically down the side of the screen, so I want to use android:layout_weight to achieve this. (Described here)
<LinearLayout
android:id="@+id/left_bar"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="8">
<Button
android:id="@+id/btnCall"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="1"
android:background="@drawable/btn_circle"
android:text="Call"
android:textSize="12sp" />
<Space
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="1"></Space>
<Button
android:id="@+id/btnSpeak"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="1"
android:background="@drawable/btn_circle"
android:text="Speak"
android:textSize="12sp" />
<Space
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="1"></Space>
<Button
android:id="@+id/btnRecordedMessage"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="1"
android:background="@drawable/btn_circle"
android:text="Recorded Message"
android:textSize="12sp" />
<Space
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="1"></Space>
<Button
android:id="@+id/btnSelectAll"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="1"
android:background="@drawable/btn_circle"
android:text="Select All Units"
android:textSize="12sp" />
<Space
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="1"></Space>
<Button
android:id="@+id/btnDeselectUnits"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="1"
android:background="@drawable/btn_circle"
android:text="Deselect Units"
android:textSize="12sp" />
<Space
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="1"></Space>
<Button
android:id="@+id/btnAnswer"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="1"
android:background="@drawable/btn_circle"
android:text="Answer"
android:textSize="12sp" />
</LinearLayout>
What ever I do I cannot seem to have them spaced out equally on any screen size let alone scaled for each of them. I think my issue is that I have to specify height & width to form the circle, but as soon as I do it messes with the layout_weight as its been (for want of a better term) 'hardcoded'.
I assume it is possible to have a vertical layout of 6 circular buttons, spaced equally down the screen but I cannot work out how? I have also tried without the <Space>
, and added padding to the <Button>
instead.