Android 我想使用“按钮样式”;Widget.Button.Transparent;在安卓工作室

Android 我想使用“按钮样式”;Widget.Button.Transparent;在安卓工作室,android,xml,button,ubuntu-16.04,android-studio-3.1.4,Android,Xml,Button,Ubuntu 16.04,Android Studio 3.1.4,当我打算使用此按钮样式时,将显示以下消息: 错误:资源android:style/Widget.Button.Transparent是私有的 有关我的系统的详细信息: 操作系统:Ubuntu 16.04 LTS Android Studio 3.1.4构建#AI-173.4907809,构建于2018年7月23日 JRE:1.8.0_152-release-1024-b01 amd64 JVM:JetBrains s.r.o提供的OpenJDK 64位服务器虚拟机 Linux 4.15.0-3

当我打算使用此按钮样式时,将显示以下消息:

错误:资源android:style/Widget.Button.Transparent是私有的

有关我的系统的详细信息:

  • 操作系统:Ubuntu 16.04 LTS
  • Android Studio 3.1.4构建#AI-173.4907809,构建于2018年7月23日
  • JRE:1.8.0_152-release-1024-b01 amd64
  • JVM:JetBrains s.r.o提供的OpenJDK 64位服务器虚拟机
  • Linux 4.15.0-33-generic
自己做就行了:

styles.xml
()中:


本文件中引用的可抽取项为九个补丁PNG,位于DPI特定位置。您可以使用android:drawable/访问它们,但如果没有,这是我能在以下位置找到的最高密度:。

您不能使用它。查看此问题以了解更多详细信息:尝试在
android:
之前和
@
之后添加
*
<代码>@*android:style/Widget.Button.Transparent“并检查发生了什么。@ઽ૯ท 我认为这只适用于AOSP。@漫游者,因为它是一个私有资源,那么我想你删除的答案会有所帮助。在
@drawable/btn\u default\u transparent
中创建自定义
按钮,然后对其进行样式设置。这似乎是最好的方法。@ઽ૯ท 是的,我删除了它,因为我意识到我需要找到额外的drawable。它又回来了。或者,它可以在我这边(下载SDK的平台文件夹)的
Android\platforms\Android-28\data\res\drawable\btn_default_transparent.xml中找到。这似乎是最好的方法+1 BTWઽ૯ท 这是XML,但它引用了一些九大补丁。当然还有一些
样式
代码,它们位于:
Android\platforms\Android-28\data\res\values\style.XML
<style name="Widget.Button.Transparent">
    <item name="background">@drawable/btn_default_transparent</item>
    <item name="textAppearance">?attr/textAppearanceSmall</item>
    <item name="textColor">@color/white</item>
</style>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2008 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_pressed="true" 
        android:drawable="@drawable/btn_default_pressed" />
    <item android:state_focused="true" android:state_enabled="true"
        android:drawable="@drawable/btn_default_selected" />
    <item android:state_enabled="true"
        android:drawable="@drawable/btn_default_transparent_normal" />
</selector>