更改 Spinner 的外观
Change how Spinner looks
首先请检查这张图片:
它显示了一个漂亮漂亮的 Spinner,我的 Spinner 看起来像这样:
这是我所有的源代码。
Activity xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="amaz1ngc0de.com.br.spinnertest.MainActivity">
<Spinner
android:id="@+id/sp_paymentType"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
</Spinner>
</RelativeLayout>
我的问题是:如何实现教程中显示的相同布局?
PS: 我已经检查了这个主题: Correct usage of a Spinner, following material design guidelines it says something about themes, but I can't make it work, and the tutorial I'm following is that one: Spinners
不幸的是,您的教程已经过时了。您显示的第一个屏幕截图是全息风格的。您创建的内容使用了更新更好的 Material 设计。干得好,你通过了教程!
但是,如果您真的想达到相同的效果,可以返回到旧外观,方法是将 activity 设置为使用 Holo 主题。您可以在 AndroidManifest.xml
:
<activity
android:name="..."
android:theme="@android:style/Theme.Holo.Light" />
或者,如果您使用的是自定义主题,则设置为父主题:
<style name="AppTheme" parent="android:Theme.Holo.Light">
如果您只想更改 Spinner
的外观,而不是整个屏幕,您可以在 Spinner
:
上使用 android:theme
<Spinner
android:id="@+id/sp_paymentType"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:theme="@android:style/Theme.Holo.Light">
首先请检查这张图片:
它显示了一个漂亮漂亮的 Spinner,我的 Spinner 看起来像这样:
这是我所有的源代码。
Activity xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="amaz1ngc0de.com.br.spinnertest.MainActivity">
<Spinner
android:id="@+id/sp_paymentType"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
</Spinner>
</RelativeLayout>
我的问题是:如何实现教程中显示的相同布局?
PS: 我已经检查了这个主题: Correct usage of a Spinner, following material design guidelines it says something about themes, but I can't make it work, and the tutorial I'm following is that one: Spinners
不幸的是,您的教程已经过时了。您显示的第一个屏幕截图是全息风格的。您创建的内容使用了更新更好的 Material 设计。干得好,你通过了教程!
但是,如果您真的想达到相同的效果,可以返回到旧外观,方法是将 activity 设置为使用 Holo 主题。您可以在 AndroidManifest.xml
:
<activity
android:name="..."
android:theme="@android:style/Theme.Holo.Light" />
或者,如果您使用的是自定义主题,则设置为父主题:
<style name="AppTheme" parent="android:Theme.Holo.Light">
如果您只想更改 Spinner
的外观,而不是整个屏幕,您可以在 Spinner
:
android:theme
<Spinner
android:id="@+id/sp_paymentType"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:theme="@android:style/Theme.Holo.Light">