Android 在Dialog中使用Spinner时,下三角图标覆盖在按钮上的解决方法
2017-09-07 10:42
726 查看
1.如果是系统开发者,则直接修改frameworks/base/core/res/res/drawable/spinner_background_material.xml为如下内容即可:
2、如果是应用开发者,则可以重新给Spinner设置background,方法如下:
1:在res/drawable 下新建 spinner_background.xml 文件,内容如下:
如果 aapt:attr 有问题的话,可以将这部分拆分成一个单独的 ic_spinner_arrow.xml (置于res/drawable中)文件,然后设置item的属性 android:drawable="@drawable/ic_spinner_arrow" ,ic_spinner_arrow.xml 内容如下:
2:在res/color 目录下新建文件 control_highlight_material.xml 文件,内容如下:
3:设置Spinner 的background 为 spinner_background
该bug现象如下:
<?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2014 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:paddingMode="stack" android:paddingStart="0dp" android:paddingEnd="24dp" android:paddingLeft="0dp" android:paddingRight="0dp"> <item android:gravity="end|center_vertical" android:width="24dp" android:height="24dp"> <!--android:drawable="@drawable/zzz_control_background_24dp_material"--> <ripple android:color="@color/control_highlight_material" android:radius="12dp"> <item android:id="@android:id/mask" android:width="24dp" android:height="24dp"> <shape android:shape="oval"> <solid android:color="@android:color/white" /> <size android:width="24dp" android:height="24dp" /> </shape> </item> <item android:width="24dp" android:height="24dp" android:drawable="@drawable/ic_spinner_caret" android:gravity="end|center_vertical"/> </ripple> </item> <!--<item--> <!--android:drawable="@drawable/ic_spinner_caret"--> <!--android:gravity="end|center_vertical"--> <!--android:width="24dp"--> <!--android:height="24dp" />--> </layer-list>
2、如果是应用开发者,则可以重新给Spinner设置background,方法如下:
1:在res/drawable 下新建 spinner_background.xml 文件,内容如下:
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" xmlns:aapt="http://schemas.android.com/aapt" android:opacity="transparent" android:paddingEnd="24dp" android:paddingLeft="0dp" android:paddingMode="stack" android:paddingRight="0dp" android:paddingStart="0dp"> <item android:width="24dp" android:height="24dp" android:gravity="end|center_vertical"> <ripple android:color="@color/control_highlight_material" android:radius="12dp"> <item android:id="@android:id/mask" android:width="24dp" android:height="24dp"> <shape android:shape="oval"> <solid android:color="@android:color/white" /> <size android:width="24dp" android:height="24dp" /> </shape> </item> <item android:width="24dp" android:height="24dp" android:gravity="end|center_vertical"> <aapt:attr name="android:drawable"> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:tint="?android:attr/colorControlNormal" android:viewportHeight="24.0" android:viewportWidth="24.0"> <path android:fillColor="#FF333333" android:pathData="M7,10l5,5,5-5z" /> </vector> </aapt:attr> </item> </ripple> </item> </layer-list>
如果 aapt:attr 有问题的话,可以将这部分拆分成一个单独的 ic_spinner_arrow.xml (置于res/drawable中)文件,然后设置item的属性 android:drawable="@drawable/ic_spinner_arrow" ,ic_spinner_arrow.xml 内容如下:
<?xml version="1.0" encoding="utf-8"?> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24.0" android:viewportHeight="24.0" android:tint="?android:attr/colorControlNormal"> <path android:pathData="M7,10l5,5,5-5z" android:fillColor="#FF333333"/> </vector>然后设置
2:在res/color 目录下新建文件 control_highlight_material.xml 文件,内容如下:
<?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2014 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_checked="true" android:state_enabled="true" android:alpha="@dimen/highlight_alpha_material_colored" android:color="?android:attr/colorControlActivated" /> <item android:color="?android:attr/colorControlHighlight" /> </selector>
3:设置Spinner 的background 为 spinner_background
该bug现象如下:
相关文章推荐
- 关于Android App上线后从应用市场点击打开按钮进入应用后进行操作后,再点击home键到桌面后点击启动图标重新打开应用的解决方法
- SkinMagic使用后按钮加自定义图标或菜单GetMneu返回NULL的解决方法
- 我的Android进阶之旅------>关于使用Android Studio替换App的launcher图标之后仍然显示默认的ic_launcher图标的解决方法
- activity使用theme.dialog且activity中有dialog时按返回按钮dialog消失activity不关闭的解决方法
- SkinMagic使用后按钮加自定义图标或菜单GetMneu返回NULL的解决方法
- android DatePickerDialog TimePickerDialog set方法执行的不规律解决以及 DatePicker TimePicker的使用
- 在android中使用proguard混淆代码出现“Conversion to Dalvik format failed with error 1”错误的解决方法
- 生成动态库so的方法|解决NDK r5b引用静态库失效的问题|在NDK的Nactive代码中使用Android Log的方法|生成Native java头文件
- Android AlertDialog解决点击按钮立即消失的问题
- 今天为大家介绍下Android的下拉单使用方法(Spinner),以及效果图。
- Android中ImageButton自定义按钮的按下效果的代码实现方法,附网上2种经典解决方法。
- 在android中使用proguard混淆代码出现“Conversion to Dalvik format failed with error 1”错误的解决方法
- android下拉菜单spinner的使用方法
- ASP.NET中使用JQuery UI Dialog致表单无法提交的解决方法
- 解决android某些应用开发某些类无法解析/找到的问题--使用android隐藏类的方法
- jquery mobile使用时dialog样式不稳定的解决方法
- 在android中使用proguard混淆代码出现“Conversion to Dalvik format failed with error 1”错误的解决方法
- Android手机无法使用debug解决方法
- Android 使用git下载源码报错解决方法
- 使用eclipse开发android时智能提示不响应的解决方法