【问题标题】:Rendering Problems in Android Studio 2.2.3Android Studio 2.2.3 中的渲染问题
【发布时间】:2017-01-02 18:00:44
【问题描述】:

每次我添加小部件或东西时,总会出现以下异常,所以我什至无法运行我的项目。是什么导致了这个问题?解决办法是什么?我是 Android Studio 的新手,希望你们能帮助我。你的每一个回答都是我的荣幸。谢谢!

这是我的 Layout.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.leeroyld.testproject.MainActivity">
    <Button
        android:text="@string/LoginButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/button"
        android:layout_marginBottom="79dp"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:background="@android:color/background_dark"
        android:backgroundTint="@android:drawable/bottom_bar"
        android:textColor="@android:color/background_light" />

    <TextView
        android:text="@string/LoginLabel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/EmailDisplay"
        android:textSize="24sp"
        android:layout_below="@+id/textView"
        android:layout_alignParentStart="true"
        android:layout_marginTop="36dp" />
    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="textPassword"
        android:ems="10"
        android:id="@+id/PasswordInput"
        tools:ignore="LabelFor"
        android:layout_marginBottom="42dp"
        android:layout_above="@+id/button"
        android:layout_centerHorizontal="true"
        android:background="?attr/actionModeBackground" />
    <TextView
        android:text="@string/PasswordLabel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/PasswordDisplay"
        android:textSize="24sp"
        android:layout_centerVertical="true"
        android:layout_alignParentStart="true" />
    <TextView
        android:text="@string/TextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/textView"
        android:textSize="24sp"
        android:layout_marginTop="31dp"
        android:background="@android:drawable/button_onoff_indicator_on"
        android:backgroundTint="@android:drawable/alert_light_frame"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true" />
    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="textEmailAddress"
        android:ems="10"
        android:id="@+id/EmailInput"
        tools:ignore="LabelFor"
        android:layout_marginTop="24dp"
        android:background="?attr/actionModeBackground"
        android:layout_below="@+id/EmailDisplay"
        android:layout_alignStart="@+id/PasswordInput" />
</RelativeLayout>

【问题讨论】:

  • 请发布您的布局。
  • 我刚刚更新了它。希望你看到它
  • 没有。布局文件。切换到文本选项卡并从那里粘贴代码。
  • 我已经发过了
  • 查看我的答案。

标签: android android-studio rendering


【解决方案1】:

LoginButtonTextView 中删除android:backgroundTint。您的最终布局应如下所示。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin">

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="79dp"
        android:background="@android:color/background_dark"
        android:text="Login"
        android:textColor="@android:color/background_light" />

    <TextView
        android:id="@+id/EmailDisplay"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView"
        android:layout_marginTop="36dp"
        android:text="Email"
        android:textSize="24sp" />

    <EditText
        android:id="@+id/PasswordInput"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/button"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="42dp"
        android:background="?attr/actionModeBackground"
        android:ems="10"
        android:inputType="textPassword"
        tools:ignore="LabelFor" />

    <TextView
        android:id="@+id/PasswordDisplay"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:text="Password"
        android:textSize="24sp" />

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="31dp"
        android:background="@android:drawable/button_onoff_indicator_on"
        android:text="TextView"
        android:textSize="24sp" />

    <EditText
        android:id="@+id/EmailInput"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/EmailDisplay"
        android:layout_marginTop="24dp"
        android:background="?attr/actionModeBackground"
        android:ems="10"
        android:inputType="textEmailAddress"
        tools:ignore="LabelFor" />
</RelativeLayout>

【讨论】:

    猜你喜欢
    • 2015-07-09
    • 2013-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-21
    相关资源
    最近更新 更多