【发布时间】:2019-05-27 16:51:58
【问题描述】:
我在 Android Studio 中打开了一个空白的 Android 应用程序,当我尝试编辑按钮时,属性不存在。我是 Android 开发新手,并且遵循了一个指南,该指南显示了如何更改按钮中的文本,但属性菜单缺少指南中的选项。
使用:
- Android Studio 3.2.1
- Gradle 4.6(从 4.5 更新)
- Android 插件版本 3.2.1
- Windows 10
我更新了 Gradle,并在没有改变界面的情况下执行了 Invalidate Caches/Restart。
我的界面看起来如何:
界面应该的外观:
A similar situation that did not resolve my issue.
通过 Android Studio 的默认文件模板创建的 revlavent XML 文件
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:text="@string/button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<EditText
android:id="@+id/editText"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:ems="10"
android:inputType="textPersonName"
android:text="Name"
tools:layout_editor_absoluteX="181dp"
tools:layout_editor_absoluteY="337dp" />
</android.support.constraint.ConstraintLayout>
【问题讨论】:
-
仔细检查您的按钮文本颜色与您的按钮背景不同
-
如果我也想更改文本颜色,我将无法更改文本颜色,因为不存在更改此类值的属性。这是一个纯文本示例i.imgur.com/BXLi1nq.png
-
可以发布您的布局
.xml文件吗? -
我相信这就是你要找的i.imgur.com/HjOZgeA.png 请记住,这是一个使用 Android Studio 的默认文件新创建的空白文件。
-
不要在此处发布图片,而是使用文本内容更新您的问题。
标签: android android-studio button gradle attributes