在制作按钮时,奇怪的工件看起来像API 21中的Spinners

时间:2015-01-17 21:49:06

标签: android android-layout android-5.0-lollipop android-support-library material-design

我有一个应用程序,我正在使用Android支持库更新为Material Design样式。在应用程序中,我有一些实际上是Button的元素,但其样式看起来像Spinner。单击时,它们会弹出日期或时间选择器,并在选择完成后更新文本。

创建这些元素的布局XML片段是:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

    <Button
        android:id="@+id/start_date"
        style="?android:attr/spinnerStyle"
        android:layout_width="0dp"
        android:layout_weight="3"
        android:hint="@string/hint_start_date"
        android:layout_height="wrap_content"/>

    <Button
        android:id="@+id/start_time"
        style="?android:attr/spinnerStyle"
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"/>

</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

    <Button
        android:id="@+id/end_date"
        style="?android:attr/spinnerStyle"
        android:hint="@string/hint_end_date"
        android:layout_width="0dp"
        android:layout_weight="3"
        android:layout_height="wrap_content"/>

    <Button
        android:id="@+id/end_time"
        style="?android:attr/spinnerStyle"
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"/>

</LinearLayout>

这与之前的版本相比没有变化,它的工作正常。从棒棒糖开始,不再像我期望的那样渲染,而是出现了一个奇怪的灰色边框(例如在Nexus 6上):

What I see on the device

当按住元素时,内部形状的底部会收缩,因此灰色三角形会变宽。

我已经尝试重写该样式,以使用我自己的(略微修改过的)原始AppCompat Library drawables副本作为背景。我已经尝试将背景强制为@null,并且工件仍在那里。 Android Studio中的渲染预览在元素的左侧显示灰色边框,我也无法删除:

Weirdness in Android Studio

我真的不知道这是从哪里来的。有什么建议?或者也许想要使用不同的UI模式?

  • 测试设备:Nexus 6,Android 5.0
  • Android studio版本:1.0.2
  • 构建工具版本:21.1.2
  • AppCompat-v7库版本:21.0.3
  • 编译SDK版本:21
  • Min SDK版本:15
  • 目标SDK版本:21

0 个答案:

没有答案
相关问题