I have a gridlayout like this in the main layout xml of my activity:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:id="@+id/parentLayout"
android:layout_gravity="right">
<GridView
android:id="@+id/gridview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#AAAAAA"
android:columnWidth="90dp"
android:numColumns="3"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:stretchMode="none"
/>
</LinearLayout>
I populate it with 6 icons by inflating the following:
<?xml version="1.0" encoding="utf-8"?>
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/searchIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/searchIcon"/>
What I want is that the gridlayout is right aligned in the linear layout and that it just wraps its content. I am testing this by giving it a different coloured background. The layout_height="wrap_content" works fine, but the width seems to have no effect. The result is this:
Any ideas?
Thanks in advance, Stephen