介绍:
随着Android 6.0.1的新版本,似乎Android对Spinner组件进行了一些更改,因为默认情况下,胡萝卜周围的内部填充更大一些.
我在一个应用程序中注意到了这一点,我没有修改代码中的任何内容,只是更新了设备上的操作系统,但是微调器的大小不同.
情况:
我有两个旋转器,一个在另一个旁边RelativeLayout(介意其余组件,我添加了所有内容,所以你可以看到这部分布局 - 删除了完全不必要的属性或视图ID)
<RelativeLayout
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/container_for_buttons_on_the_right"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true">
<!-- Buttons here-->
</LinearLayout>
<android.support.v7.widget.AppCompatSpinner
android:id="@+id/spinner_1"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<ViewSwitcher
android:id="@+id/spinner_switch"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_toEndOf="@id/spinner_1"
android:layout_toLeftOf="@id/container_for_buttons_on_the_right"
android:layout_toRightOf="@id/spinner_1"
android:layout_toStartOf="@id/container_for_buttons_on_the_right"
android:inAnimation="@anim/fade_in"
android:outAnimation="@anim/fade_out">
<android.support.v7.widget.AppCompatSpinner
android:layout_width="wrap_content"
android:layout_height="match_parent" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<!-- ImageView properties are incomplete but I need it there.-->
</ViewSwitcher>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
Spinner适配器用于该getView()方法的布局如下:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="48dp"
android:orientation="horizontal"
android:paddingLeft="8dp"
android:paddingRight="8dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:ellipsize="end"
android:gravity="center_vertical"
android:singleLine="true"
tools:text="Test" …Run Code Online (Sandbox Code Playgroud) android android-layout android-spinner android-6.0-marshmallow android-6.0.1-marshmallow
android ×1