How to vertically centre elements in a ListView?
I have a number of Switch elements laid out in a ListView. Currently
they're appearing as follows:
but I need them to be vertically centred, e.g.
I'm using the following AXML as the definition for each list item:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget32"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Switch
android:id="@+id/switchOutput"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:text="[Output Name]"
android:gravity="center_vertical" />
<ImageButton
android:id="@+id/imgTime"
android:background="@null"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/datetime"
android:scaleType="fitCenter"
android:layout_alignParentRight="true" />
</RelativeLayout>
I thought android:gravity="center_vertical" would be enough to get them to
appear correctly, but it doesn't appear to be working. What do I need to
get the switches vertically centred in each list item?
No comments:
Post a Comment