Android значок выпадающего меню блесны скрывается под фоновым изображением - PullRequest
1 голос
/ 24 января 2020

Я использую Spinner в моем android приложении, где я использую Spinner в LinearLayout, и я использую Relative Layout с фоновым изображением и LinerLayout внутри FrameLayout, чтобы показать фоновое изображение. В этом случае моя выпадающая иконка скрывается за фоновым изображением. Вот мой пример кода.

<FrameLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:minWidth="25px"
        android:minHeight="25px"
        android:layout_width="match_parent"
        android:orientation="vertical"
        android:background="#FFFF"
        android:layout_height="match_parent"
        android:id="@+id/mainLinearLayout">
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="bottom"
        android:id="@android:id/background"
        android:background="@drawable/devbg"/>
    <LinearLayout
        android:minWidth="25px"
        android:minHeight="25px"
        android:layout_width="match_parent"
        android:orientation="vertical"
        android:layout_height="match_parent"
        android:id="@+id/linearLayout1"> 
      <Spinner
            android:id="@+id/dropStatus"
            style="@style/Base.Widget.AppCompat.DropDownItem.Spinner"
            android:theme="@style/CardView.Dark"
            android:spinnerMode="dropdown"
            android:layout_width="180dp"
            android:layout_height="30dp"
            android:layout_marginBottom="7dp"
            android:layout_marginLeft="5dp"
            android:textSize="16dp"
            android:foregroundTint="#FF000000"
            android:backgroundTint="#FF000000"
            android:textAlignment="center"
            android:drawSelectorOnTop="true"/> 
   </LinearLayout>
</FrameLayout>

Ответы [ 2 ]

1 голос
/ 28 января 2020

Я не знаю, почему вы используете RelativeLayout для установки фона. Удалите его и установите фон в LinearLayout, все будет хорошо.

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:minWidth="25px"
    android:minHeight="25px"
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:background="#FFFF"
    android:layout_height="match_parent"
    android:id="@+id/mainLinearLayout">
<LinearLayout
    android:minWidth="25px"
    android:minHeight="25px"
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:layout_height="match_parent"
    android:id="@+id/linearLayout1"
    android:background="@drawable/pink"> 
  <Spinner
        android:id="@+id/dropStatus"
        style="@style/Base.Widget.AppCompat.DropDownItem.Spinner"
        android:theme="@style/CardView.Dark"
        android:spinnerMode="dropdown"
        android:layout_width="180dp"
        android:layout_height="30dp"
        android:layout_marginBottom="7dp"
        android:layout_marginLeft="5dp"
        android:textSize="16dp"
        android:foregroundTint="#FF000000"
        android:backgroundTint="#FF000000"
        android:textAlignment="center"
        android:drawSelectorOnTop="true"/> 
 </LinearLayout>
</FrameLayout>

enter image description here

0 голосов
/ 24 января 2020

Обновлено

Вы можете попробовать этот код?

<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:orientation="vertical"
android:background="#FFFF"
android:layout_height="match_parent"
android:id="@+id/mainLinearLayout">
<ImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="bottom"
    android:id="@android:id/background"
    android:src="@drawable/devbg"/>
<LinearLayout
    android:minWidth="25px"
    android:minHeight="25px"
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:layout_height="match_parent"
    android:id="@+id/linearLayout1">
    <Spinner
        android:id="@+id/dropStatus"
        style="@style/Base.Widget.AppCompat.DropDownItem.Spinner"
        android:theme="@style/CardView.Dark"
        android:spinnerMode="dropdown"
        android:layout_width="180dp"
        android:layout_height="30dp"
        android:layout_marginBottom="7dp"
        android:layout_marginLeft="5dp"
        android:textSize="16dp"
        android:foregroundTint="#FF000000"
        android:backgroundTint="#FF000000"
        android:textAlignment="center"
        android:drawSelectorOnTop="true"/>
</LinearLayout>
</FrameLayout>
...