0

i've a strange problem when i set android:layout_width="fill_parent" in my Spinner:

the clickable area is reduced to a line (red square) and only pressing on this line is possibile show the elements of the Spinner: enter image description here

if i use android:layout_width="wrap_content" i obtain the correct area: enter image description here

i would like the same thing using "fill_parent" enter image description here

The elements of the Spinner are correctly visualized.. The only problem is clicking on the Spinner. Which is the possible problem?

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#040404"
    android:gravity="center"
    android:paddingTop="2dp"
    android:weightSum="4" >

    <TextView
        android:id="@+id/mpp_movimento_lbl"
        android:background="@drawable/selector_black_btn"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:drawableTop="@drawable/freccia_verde"
        android:gravity="center"
        android:text="@string/Movimento"
        android:textColor="@color/white"
        android:textStyle="bold"
        android:textSize="17sp" />

    <TextView
        android:id="@+id/mpp_eccesso_lbl"
        android:background="@drawable/selector_black_btn"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:drawableTop="@drawable/freccia_rossa"
        android:gravity="center"
        android:text="@string/Eccesso"
        android:textColor="@color/white"
        android:textStyle="bold"
        android:textSize="17sp" />

    <TextView
        android:id="@+id/mpp_fermo_lbl"
        android:background="@drawable/selector_black_btn"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:drawableTop="@drawable/freccia_grigia"
        android:gravity="center"
        android:text="@string/Fermo"
        android:textColor="@color/white"
        android:textStyle="bold"
        android:textSize="17sp" />

    <TextView
        android:id="@+id/mpp_ripristina_lbl"
        android:background="@drawable/selector_black_btn"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:drawableTop="@drawable/ripristina_mappa_40x40"
        android:gravity="center"
        android:text="@string/Ripristina"
        android:textColor="@color/white"
        android:textStyle="bold"
        android:textSize="17sp" />

</LinearLayout>

<TextView
    android:id="@+id/mpp_automezzi_visualizzati_lbl"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/black"
    android:gravity="center"
    android:paddingTop="5dp"
    android:text="@string/AutomezziVisualizzati"
    android:textColor="@color/white"
    android:textSize="17sp" />

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/white"
    android:paddingTop="5dp" >

    <FrameLayout
        android:id="@+id/mpp_spinner_frame_fly"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_toLeftOf="@+id/mpp_cerca_btn" >

        <Spinner
            android:id="@+id/mpp_spinner_spn"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="right"
            android:textSize="17sp" />

    </FrameLayout>

    <ImageButton
        android:id="@+id/mpp_cerca_btn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:layout_marginLeft="5dp"
        android:background="@drawable/selector_white_btn"
        android:contentDescription="@string/DescrizioneCerca"
        android:gravity="center"
        android:onClick="doCerca"
        android:src="@drawable/cerca" />
</RelativeLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="5dp"
    android:background="#040404"
    android:gravity="center" >
</LinearLayout>

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <fragment
        android:id="@+id/mpp_mappa_fragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        class="com.google.android.gms.maps.SupportMapFragment" />

</RelativeLayout>

4

1 回答 1

2

Try setting your Spinner's parent's height to match_parent. And also do you really need such layout? There is no need to place spinner in FrameLayout, try setting spinners's weight to 1 and replace RelativeLayout with LinearLayout

于 2013-07-31T08:36:11.710 回答