Android 活动UI元素未显示

Android 活动UI元素未显示,android,android-layout,android-studio,Android,Android Layout,Android Studio,当应用程序运行时,向我的活动添加UI元素不会改变任何内容-我得到一个空活动。 我已附加我的活动布局、清单和样式文件 活动布局: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="ma

当应用程序运行时,向我的活动添加UI元素不会改变任何内容-我得到一个空活动。 我已附加我的活动布局、清单和样式文件

活动布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"
android:id="@+id/activity_main"
android:clickable="false">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="text"
    android:id="@+id/textView"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="75dp"
    android:visibility="visible"
    android:editable="false" />

清单看起来像:

<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="myTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowNoTitle">false</item>
    <item name="windowActionBar">false</item>
    <item name="android:windowFullscreen">true</item>
</style>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
</style>


样式如下所示:

<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="myTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowNoTitle">false</item>
    <item name="windowActionBar">false</item>
    <item name="android:windowFullscreen">true</item>
</style>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
</style>

假的
假的
真的

你的主要活动是什么?你用过吗

setContentView(R.layout.main_activity)

在onCreate()?

中,我发现了问题。显然,声明了一个webView

setContentView(webView);

在我的主要活动中

确保使用正确的oncreate()方法,因为我们有两种方法:

public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState)


我最近开始在android上开发时也遇到了同样的问题。 问题是我在活动的
onCreate(Bundle savedInstanceState)
方法中运行了一个无限循环

尽管所有元素都存在于布局中,但由于活动在创建后进入无限循环,因此没有呈现任何UI元素


希望这有助于部分解决我的问题。在创建(@Nullable Bundle savedInstanceState)和
setContentView
时使用了受保护的void。