java - XML 布局问题

标签 java android xml

我想扩展我的 XML 布局,因为我需要在一个屏幕上放置许多按钮。我在 TextView 和 ImageView 下添加了 ScrollView ,但似乎无法扩展布局?我的 ScrollView 上还收到 XML 错误布局:

error: Error parsing XML: mismatched tag

这是我的布局,显示了扩展问题。谁能告诉我我做错了什么?:

pic

这是我的 XML - 我知道我有重复的信息。这是一个测试。:

<?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="wrap_content"
android:orientation="vertical" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="84dp"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/imgLink"
        android:layout_width="60dp"
        android:layout_height="match_parent"
        android:layout_gravity="center_vertical"
        android:layout_weight="0.91"
        android:src="@drawable/menulist" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="165dp"
        android:layout_height="match_parent"
        android:layout_weight="0.14"
        android:gravity="center"
        android:text="Menu"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textSize="40sp" />

</LinearLayout>

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <Button
        android:id="@+id/btnAdd"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="20dp"
        android:drawableLeft="@drawable/addconmenu"
        android:src="@drawable/addconmenu"
        android:text="Contacts List" />

    <Button
        android:id="@+id/btnView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="20dp"
        android:drawableLeft="@drawable/todo"
        android:src="@drawable/todo"
        android:text="&apos;To Do&apos; List" />

    <Button
        android:id="@+id/btnEdit"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="20dp"
        android:drawableLeft="@drawable/musicmenu"
        android:src="@drawable/musicmenu"
        android:text="Music List" />

       <Button
           android:id="@+id/btnEdit"
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           android:layout_margin="20dp"
           android:drawableLeft="@drawable/shoppingmenu"
           android:src="@drawable/shoppingmenu"
           android:text="Shopping List" />

           <Button
               android:id="@+id/btnEdit"
               android:layout_width="match_parent"
               android:layout_height="wrap_content"
               android:layout_margin="20dp"
               android:drawableLeft="@drawable/gymmenu"
               android:src="@drawable/gymmenu"
               android:text="Gym List" />

           <Button
               android:id="@+id/btnEdit"
               android:layout_width="match_parent"
               android:layout_height="wrap_content"
               android:layout_margin="20dp"
               android:drawableLeft="@drawable/appointmentmenu"
               android:src="@drawable/appointmentmenu"
               android:text="Appointment List" />

</LinearLayout>

</LinearLayout>
</ScrollView>

最佳答案

看起来您应该颠倒布局最后两行的顺序。您将在关闭顶级 LinearLayout 标记后关闭 ScrollView 标记。

关于java - XML 布局问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14386278/

相关文章:

android - 错误 : YouTubeService has leaked IntentReceiver . .. 您是否错过了对 unregisterReceiver() 的调用?

java - 如何在 Web 应用程序中加载多个 XSD?

python - 使用python显示xml中元素的内容

java - 为什么这段java代码没有捕获所有异常

java - 使用 Astyanax 将 Cassandra 查询结果转换为 POJO

java - 安卓查询参数

java - 从 android 上的名称和内存问题实例化 java 类

java - 从 XML 字符串获取值

java - 使用java监控unix系统性能

java - 如何使用 "sendMessage()"代码发送 double ?