1

我打算在我的edittext上添加一个阴影我知道如何添加阴影但我也想在它上面添加一个选择器如何同时添加选择器和阴影?

选择器:

    <?xml version="1.0" encoding="utf-8"?>
<!--  res/drawable/rounded_edittext.xml -->
<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item android:state_pressed="true" android:state_focused="true">
    <shape>
        <solid
            android:color="#3f3f3f"/>
        <stroke
            android:width="2.3dp"
            android:color="#656565" />
          <corners
            android:radius="2dp" />    
    </shape>
</item>

<item android:state_pressed="true" android:state_focused="false">
    <shape>
        <solid
            android:color="#3f3f3f"/>
        <stroke
            android:width="2.3dp"
            android:color="#656565" />      
          <corners
            android:radius="2dp" />        
    </shape>
</item>

<item android:state_pressed="false" android:state_focused="true">
    <shape>
        <solid
            android:color="#3f3f3f"/>
        <stroke
            android:width="2.3dp"
            android:color="#656565" />  
          <corners
            android:radius="2dp" />                           
    </shape>
</item>

<item android:state_pressed="true" android:state_focused="true">
    <shape>
        <stroke
            android:width="2.3dp"
            android:color="#F6EBC9" />
         <corners
            android:radius="10dp" />
    </shape>
</item>

<item android:state_enabled="true">
    <shape>
        <solid
            android:color="#3f3f3f"/>
        <padding 
                android:left="4dp"
                android:top="4dp"
                android:right="4dp"
                android:bottom="4dp"
            />
    </shape>
</item>

</selector>

阴影:

  <?xml version="1.0" encoding="utf-8"?>
 <layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<!-- most improtant is order of layers -->

<!-- Bottom right side 2dp Shadow -->
<item >
    <shape android:shape="rectangle">
        <solid android:color="#000000" />          
    </shape>
</item>

<!-- Bottom 2dp Shadow -->
<item>
    <shape android:shape="rectangle">
        <solid android:color="#000000" />  
    </shape>
</item>

<!-- White Top color -->
<item android:bottom="3px" android:right="3px">
    <shape android:shape="rectangle">
        <solid android:color="#FFFFFF" />          
    </shape>
</item>

编辑文本:

 <EditText
    android:id="@+id/searchScreen2Edittext"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/textinputborder"
    android:ems="10"
    android:hint="Search Bus Station..."
    android:imeOptions="actionDone"
    android:inputType="textVisiblePassword"
    android:padding="8dip"
    android:textSize="18sp"

    android:shadowColor="#000000"
    android:shadowDx="1.2"
    android:shadowDy="1.2"
    android:shadowRadius="1.5"
    >

我不知道如何实现这两者,因为我可以同时添加两个背景.. 怎么做?

4

0 回答 0