<少女> 2022-09-14 15:48 采纳率: 90.9%
浏览 17
已结题

为什么我这里都有显示但是手机模拟器却没有显示出来?


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

    <Button
        android:id="@+id/btn"
        android:text="中"
        android:layout_centerInParent="true"
        android:layout_width="100dp"
        android:layout_height="50dp"
        />
    <Button
        android:layout_toLeftOf="@id/btn"
        android:layout_centerVertical="true"
        android:text="左"
        android:layout_width="100dp"
        android:layout_height="50dp"
        />
    <Button
       android:layout_toRightOf="@id/btn"
        android:layout_centerVertical="true"
        android:text="右"
        android:layout_width="100dp"
        android:layout_height="50dp"
        />
    <Button
        android:layout_above="@id/btn"
        android:text="上"
        android:layout_centerHorizontal="true"
        android:layout_width="100dp"
        android:layout_height="50dp"
        />
    <Button
        android:layout_above="@id/btn"
        android:layout_toLeftOf="@id/btn"
        android:text="左上"
        android:layout_centerHorizontal="true"
        android:layout_width="100dp"
        android:layout_height="50dp"
        />
    <Button
        android:layout_above="@id/btn"
        android:layout_toRightOf="@id/btn"
        android:text="右上"
        android:layout_centerHorizontal="true"
        android:layout_width="100dp"
        android:layout_height="50dp"
        />
    <Button
        android:layout_below="@id/btn"
        android:text="下"
        android:layout_centerHorizontal="true"
        android:layout_width="100dp"
        android:layout_height="50dp"
        />
    <Button
        android:layout_below="@id/btn"
        android:layout_toRightOf="@id/btn"
        android:text="右下"
        android:layout_centerHorizontal="true"
        android:layout_width="100dp"
        android:layout_height="50dp"
        />
    <Button
        android:layout_below="@id/btn"
        android:layout_toLeftOf="@id/btn"
        android:text="左下"
        android:layout_centerHorizontal="true"
        android:layout_width="100dp"
        android:layout_height="50dp"
        />


</RelativeLayout>


为什么我这里都有显示但是手机模拟器却没有显示出来?

img

  • 写回答

4条回答 默认 最新

  • 不会写代码的猴子 Android领域优质创作者 2022-09-14 16:04
    关注

    盲猜你的MainActivity中是

    setContentView(R.layout.activity_main);
    

    而你在

    img


    这里添加的

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

问题事件

  • 系统已结题 9月30日
  • 已采纳回答 9月22日
  • 创建了问题 9月14日

悬赏问题

  • ¥15 对于知识的学以致用的解释
  • ¥50 三种调度算法报错 有实例
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败