android - My Spinner View has an elevation shadow acquired from its parent -


i have linearlayout 2 children: textview , spinner. linearlayout, acquired theme defined in style.xml file, has elevation value create shadow. however, reason, spinner getting shadow well. seems acquiring parent. if remove android:theme property linearlayout parent, shadow on both layout , spinner go away.

what going on here? spinner not have shadow.

also, if make custom theme spinner , set elevation 0dp, rid of shadow, spinner runs other layout problems. know i'm doing wrong here...

here code.

layout section:

        <linearlayout             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:layout_marginbottom="5dp"             android:layout_marginleft="10dp"             android:layout_marginright="10dp"             android:layout_margintop="5dp"             android:background="@drawable/section_background"             android:orientation="vertical"             android:theme="@style/apptheme.section">              <textview                 android:id="@+id/titlecalendar"                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:layout_marginbottom="10dp"                 android:layout_marginleft="10dp"                 android:layout_margintop="5dp"                 android:text="calendar"                 android:textappearance="?android:attr/textappearancemedium"                 android:textstyle="bold" />              <spinner                 android:id="@+id/calendarspinner"                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:layout_marginbottom="10dp"                 android:layout_marginright="20dp"                 android:layout_marginleft="20dp"/>         </linearlayout> 

theme of linearlayout (@style/apptheme.section):

        <style name="apptheme.section">             <item name="android:elevation">6dp</item>         </style> 

java code fill spinner options:

     string[] spinneritems = new string[]{             "hello",             "i love you",             "this test"     };      calendarspinner = (spinner) findviewbyid(r.id.calendarspinner);      arrayadapter<string> adapter = new arrayadapter<string>(this, android.r.layout.simple_spinner_item, spinneritems);     adapter.setdropdownviewresource( android.r.layout.simple_spinner_dropdown_item );     calendarspinner.setadapter(adapter); 

here how looks on device:

enter image description here

now, if add custom theme spinner...

<spinner      android:id="@+id/calendarspinner"      android:layout_width="match_parent"      android:layout_height="wrap_content"      android:layout_marginbottom="10dp"      android:layout_marginright="20dp"      android:layout_marginleft="20dp"      android:theme="@style/spinnertheme"/> 

style:

 <style name="spinnertheme" parent="apptheme.spinnerbase">       <item name="android:elevation">0dp</item>  </style> 

style parent (apptheme.spinnerbase):

 <style name="apptheme.spinnerbase" parent="widget.appcompat.spinner.underlined">  </style> 

here end with:

enter image description here


enter image description here

the spinner dropdown has line , spinner arrow on right!

inside xml layout can set elevation 0.

 <spinner  android:id="@+id/calendarspinner"  android:layout_width="match_parent"  android:layout_height="wrap_content"  android:layout_marginbottom="10dp"  android:layout_marginright="20dp"  android:layout_marginleft="20dp"  android:elevation="0dp"/> 

the element ignored in earlier version of android if not recognized. aware putting elements in xml on devices result in arguments follow unrecognized 1 ignored, don't put first argument.


Comments