我以前没有使用过自定义样式。 我想将我的应用程序中EditText的样式定制为与下面的图像完全相同。
我不是要求您为我设计它。 只需指点我正确的方向即可。 先感谢您!
我以前没有使用过自定义样式。 我想将我的应用程序中EditText的样式定制为与下面的图像完全相同。
我不是要求您为我设计它。 只需指点我正确的方向即可。 先感谢您!
您可以使用图层列表进行样式设置。在drawable文件夹中创建此文件bg_search.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@android:color/darker_gray" />
<corners android:radius="5dp" />
</shape>
</item>
<item
android:bottom="2dp"
android:left="1dp"
android:right="1dp">
<shape android:shape="rectangle">
<solid android:color="@android:color/white" />
<corners android:radius="5dp" />
</shape>
</item>
</layer-list>
并将其应用为您的 EditText
的背景
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_search"
android:drawableLeft="@android:drawable/ic_menu_search"
android:drawablePadding="15dp"
android:hint="Search SoundCloud"
android:padding="16dp" />