You must supply a layout_width attr

android启动的时候,logCat中报错:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.lby.myfirstApp/com.lby.myfirstApp.MainActivity}: java.lang.RuntimeException: Binary XML 

file line #23: You must supply a layout_width attribute.

原因是TextView缺少 layout_width 属性所致,加上就可以了。


<Button 
android:id="@+id/jumpButton"
   android:text="点击跳转到第二个textView"
   android:layout_width="match_parent" 
android:layout_height="wrap_content"
   />

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下代码,请帮我将Textview修改为一个imageview 。谢谢 。<?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" xmlns:didi="http://schemas.android.com/apk/res-auto" > <com.blog.demo10.NestedViewGroup android:id="@+id/dd_view_group" android:layout_width="match_parent" android:layout_height="match_parent" didi:header_id="@+id/view_bg" didi:target_id="@+id/target_layout" didi:inn_id="@+id/inner_rv" didi:header_init_top="0" didi:target_init_bottom="250"> <TextView android:id="@+id/view_bg" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:textColor="#f00" android:textSize="25sp" android:textAllCaps="false" android:text="@string/txt_nested_scroll_bg" /> <LinearLayout android:id="@+id/target_layout" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:background="#fff"> <androidx.recyclerview.widget.RecyclerView android:id="@+id/inner_rv" android:layout_width="match_parent" android:layout_height="wrap_content"/> </LinearLayout> </com.blog.demo10.NestedViewGroup> <androidx.appcompat.widget.Toolbar android:id="@+id/my_toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" android:elevation="4dp" android:theme="@style/ThemeOverlay.AppCompat.ActionBar" didi:popupTheme="@style/ThemeOverlay.AppCompat.Light"/> </RelativeLayout>
最新发布
06-06

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值