提问者:小点点

设计视图上不显示编辑文本框-Android Studio


我需要帮助,因为编辑文本框没有显示在Android工作室的设计视图。

布局XML文件

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
    android:id="@+id/relativeLayout">

    <EditText
        android:id="@+id/username"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="First Name"
        android:inputType="text"
        />

</RelativeLayout>

这是快照。 我为edittext编写了代码,但它在设计视图上不可见。


共2个答案

匿名用户

向edittext添加样式属性

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:id="@+id/relativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">



<EditText
    style="@style/EditText.RoundBorder"        //add this line then you might be able to see
    android:id="@+id/username"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="First Name"
    android:inputType="text"
    />
</RelativeLayout>

匿名用户

您可以尝试将宽度设置为match_parent,将高度设置为原来的高度。 如果连这都不起作用,试着重建项目。 有时您通过代码添加的内容不会立即反映在设计窗口中。 或者可以删除此编辑文本,从“设计”窗口手动拖放编辑文本。 然后可以从XML文件中更改它的属性