I'm trying to build a simple Activity View with a LinearLayout containing a 
GridView followed by an ImageButton. My main.xml contains the following:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android";
android:id="@+id/buttons" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="horizontal">
<GridView xmlns:android="http://schemas.android.com/apk/res/android";
android:id="@+id/gridview" android:layout_width="wrap_content"
android:layout_height="match_parent" 
android:columnWidth="@dimen/word_image_width"
android:numColumns="auto_fit" android:verticalSpacing="10dp"
android:horizontalSpacing="10dp" android:stretchMode="columnWidth"
android:gravity="center" android:background="#FFFFFFFF" />
<ImageButton xmlns:android="http://schemas.android.com/apk/res/android";
android:id="@+id/nextWordGroup" android:src="@drawable/next_arrow"
android:layout_height="match_parent" android:layout_width="wrap_content"
android:gravity="center" android:background="#FFFFFFFF" />
</LinearLayout>


My GridView adapter contains the following getView() method:

    public View getView(int position, View convertView, ViewGroup parent) {
    FrameLayout frameLayout;
        ImageView imageView;
        if (convertView == null) {  // if it's not recycled, initialize some 
attributes
            Resources res = context.getResources();
            imageView = new ImageView(context);
            imageView.setId(position);
            imageView.setLayoutParams(new 
GridView.LayoutParams((int)res.getDimension(R.dimen.word_image_width), 
            (int)res.getDimension(R.dimen.word_image_height)));
            imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
            positionToViewMap.put(position, imageView);
        } else {
        imageView = (ImageView) convertView;
        }
        
        try {
imageView.setImageBitmap(AssetUtilWithNewStuff.getBitmapFromAsset(context, 
createFilePath(imageFiles[position])));
} catch (IOException e) {
e.printStackTrace();
 }
        return imageView;
    } 


When I run the application, the GridView is displayed, but the ImageButton 
specified in main.xml is not displayed. The GridView simply takes up the 
entire screen. But if I reverse the order of the Views in main.xml with 
ImageButton first, followed by GridView, they are both displayed. I've spent 
a lot of time fiddling with the parameters of the GridView, the ImageButtons 
that are added to it by the GridView adapter, and the ImageButton that is 
spec'd on main.xml. But no luck. Could use some help.

Thanks,

Rick

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to