android - "No XML content. Please add a root view or layout to your document"

标签 android xml android-softkeyboard

当我在 main.xml 图形 View 中编码(参见下面的代码)时,我正在尝试为 2.1 及更高版本编写软键盘,但不显示任何内容并显示无 XML 内容。请在您的文档中添加 Root View 或布局”我已经尝试将代码放在 textview 中,但仍然没有运气,我根本无法让软键盘显示,就好像我的代码被忽略了..我已经尝试了这两个单独编码没有任何作用

<com.example.android.softkeyboard.LatinKeyboardView
xmlns:android="http://schemas.android.com/apk/res/android"

    android:id="@+id/keyboard"
    android:layout_alignParentBottom="true"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
/>
<Keyboard
    android:keyWidth="%10p"
    android:keyHeight="50px"
    android:horizontalGap="2px"
    android:verticalGap="2px" >
   <Row android:keyWidth="32px" >
   <Key android:keyLabel="A" />
...
</Row>
...
</Keyboard>

最佳答案

请把你的代码放在线性布局中

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<com.example.android.softkeyboard.LatinKeyboardView

android:id="@+id/keyboard"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<Keyboard
android:keyWidth="%10p"
android:keyHeight="50px"
android:horizontalGap="2px"
android:verticalGap="2px" >
<Row android:keyWidth="32px" >
<Key android:keyLabel="A" />
...
</Row>
...
</Keyboard>
</LinearLayout>

关于android - "No XML content. Please add a root view or layout to your document",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9987788/

相关文章:

java - 如何在android中使底部导航栏不透明?

java - 在 Android 中重现一个简单的 Foreach 循环?

java - Android,Imageview,几个问题

android - 如何在设备启动时显示通知

xml - 如何选择具有特定属性的所有元素?使用 TinyXPath

javascript - Fetch API 返回状态代码 0,需要 XML 响应

c++ - 使用 C++ boost 属性树在多个标签上具有相同属性的 XML

java - 在 Android 的 EditText 中更改用户输入的字符

android - 如何通过非 Activity 类从另一个 Activity 获取数据

Android 自定义键盘 - 如何检测请求的键盘类型