Android: how to shrink image when spinner is tapped

I have a window with one spinner at the bottom and one image at the top that fills the remaining space.

When i tap on the spinner it does nothing, like it’s blocked. I assume it’s due to the image leaving no available space for the expanded spinner to show.

So, i tried to add a touchListener so i would be able to change the image’s visibility to GONE and make room for the list of items to appear.

However, said listener is never been invoked when the image is present. If i remove the image in the xml, it gets invoked.

I also added an OnItemSelectedListener, but things go the same way: if the image is present, neither onNothingSelected nor onItemSelected are called, if i remove the image, they get called accordingly.

My question is: how do i shrink the image when the spinner is tapped so the user can see the options available inside it?

sp.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                Log.d("SPINNER TOUCHED!!!!", "dasdsada");
                return false;
            }
        });

<?xml version="1.0" encoding="utf-8"?> 

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context="nnn.MainActivity">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/image1"
        android:layout_weight="1"/>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        >
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="v1" />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="select somethung" />
        <Spinner
        android:id="@+id/stuff_spinner"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />

    <Button
        android:layout_width="423dp"
        android:layout_height="wrap_content"
        android:text="Next"
        android:onClick="DoNext"/>
</LinearLayout>
    </LinearLayout>

Thank you

I know nothing at all about Android programming, so that is my excuse in case this is a useless comment. :tongue:

If this were an HTML/CSS document, I would consider that your analysis is completely correct and would look to see if it is possible to place the spinner in a layer above the image by assigning a higher z-index to the spinner than that which the image might have. (They need a common ancestor for the z-index thing to work.) There is also a new CSS property called pointer-events that can allow a click or tap to pass through a top element (the image in this case) and act on the element in the next layer below (the spinner).

Perhaps one of these concepts will be something you can relate to in Android programming.

I like the layering idea. Gonna check it. Thanks.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.