EditText中文本没有显示出来

EditText中文本没有显示出来

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:stretchColumns="*"
   tools:context=".TableLayout">
   <!--如果直接往TableLayout中添加控件,那么该控件与屏幕等宽
       如果想使多个控件在同一行,那么我们在这些控件外层包裹一对TableRow
       并且在这种情况下,控件宽度与内容适配
       android:stretchColumns="*" 设置
       android:layout_span="2"  跨列2
       -->
   <EditText
       android:layout_weight="2"
       android:text="0"
       android:gravity="right|center_vertical"
       android:textSize="28sp"
       />
   <TableRow android:layout_weight="1">

       <Button
           android:layout_height="match_parent"
           android:text="C"
           android:textSize="24sp"/>

       <Button
           android:layout_height="match_parent"
           android:text="+/-"
           android:textSize="24sp"/>

       <Button
           android:layout_height="match_parent"
           android:text="%"
           android:textSize="24sp"/>

       <Button
           android:layout_height="match_parent"
           android:text="÷"
           android:textSize="24sp"/>
   </TableRow>

   <TableRow android:layout_weight="1">

       <Button
           android:layout_height="match_parent"
           android:text="7"
           android:textSize="24sp"/>

       <Button
           android:layout_height="match_parent"
           android:text="8"
           android:textSize="24sp"/>

       <Button
           android:layout_height="match_parent"
           android:text="9"
           android:textSize="24sp"/>

       <Button
           android:layout_height="match_parent"
           android:text="*"
           android:textSize="24sp"/>
   </TableRow>

   <TableRow android:layout_weight="1">

       <Button
           android:layout_height="match_parent"
           android:text="4"
           android:textSize="24sp"/>

       <Button
           android:layout_height="match_parent"
           android:text="5"
           android:textSize="24sp"/>

       <Button
           android:layout_height="match_parent"
           android:text="6"
           android:textSize="24sp"/>

       <Button
           android:layout_height="match_parent"
           android:text="-"
           android:textSize="24sp"/>
   </TableRow>

   <TableRow android:layout_weight="1">

       <Button
           android:layout_height="match_parent"
           android:text="1"
           android:textSize="24sp"/>

       <Button
           android:layout_height="match_parent"
           android:text="2"
           android:textSize="24sp"/>

       <Button
           android:layout_height="match_parent"
           android:text="3"
           android:textSize="24sp"/>

       <Button
           android:layout_height="match_parent"
           android:text="+"
           android:textSize="24sp"/>
   </TableRow>

   <TableRow android:layout_weight="1">

       <Button
           android:layout_height="match_parent"
           android:text="0"
           android:textSize="24sp"
           android:layout_span="2"/>

       <Button
           android:layout_height="match_parent"
           android:text="."
           android:textSize="24sp"/>

       <Button
           android:layout_height="match_parent"
           android:text="="
           android:textSize="24sp"/>

   </TableRow>
</TableLayout>

http://img1.sycdn.imooc.com//climg/60bee7e809e39ecd14390362.jpg

正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

1回答
LovelyChubby 2021-06-08 13:22:23
 <EditText
       android:layout_weight="2"
       android:text="0"
       android:gravity="right|center_vertical"
       android:textSize="28sp"
       />

你没指定EditText的宽高,要她怎么显示呢?

  • 提问者 weixin_慕神2237487 #1

    视频中老师的可以哎

    http://img1.sycdn.imooc.com//climg/60bf06bc09dc7b6d13240733.jpg

    2021-06-08 13:57:18
  • LovelyChubby 回复 提问者 weixin_慕神2237487 #2

    你这段代码我放到android studio,是没有问题的哈。 可能是你的ide有问题哈,可以运行到手机上,看下真实效果

    http://img1.sycdn.imooc.com//climg/60c4b6f509c052bc06281010.jpg



    2021-06-12 21:31:14
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师