android之layout_toLeftOf和layout_toRightOf出现的错误

错误是这样的,布局文件如下,总是在SeekBar里面的这一句android:layout_toLeftOf="@id/voice_max"报错,差点气得我吐血,明明没有错误的.

 

  1. <ImageView   
  2.             android:id="@+id/voice_min"  
  3.             android:layout_width="wrap_content"  
  4.             android:layout_height="wrap_content"  
  5.             android:layout_alignParentLeft="true"  
  6.             android:layout_centerVertical="true"  
  7.             android:background="@drawable/voice_min"/>  
  8. <SeekBar   
  9.             android:id="@+id/sb_voice"  
  10.             android:layout_height="wrap_content"  
  11.             android:layout_width="fill_parent"  
  12.             android:layout_centerVertical="true"  
  13.             android:layout_toLeftOf="@id/voice_max"  
  14.             android:layout_toRightOf="@id/voice_min"  
  15.             android:paddingLeft="5dp"  
  16.             android:paddingRight="5dp"  
  17.             android:background="@drawable/voice_seekbar_bg"  
  18.             />  
  19. <ImageView   
  20.             android:id="@+id/voice_max"  
  21.             android:layout_height="wrap_content"  
  22.             android:layout_width="wrap_content"  
  23.             android:layout_alignParentRight="true"  
  24.             android:layout_centerVertical="true"  
  25.             android:background="@drawable/voice_max"/>  


 

后来我尝试作了修改,如下

 

  1. <ImageView   
  2.         android:id="@+id/voice_min"  
  3.         android:layout_width="wrap_content"  
  4.         android:layout_height="wrap_content"  
  5.         android:layout_alignParentLeft="true"  
  6.         android:layout_centerVertical="true"  
  7.         android:background="@drawable/voice_min"/>  
  8.     <ImageView   
  9.         android:id="@+id/voice_max"  
  10.         android:layout_height="wrap_content"  
  11.         android:layout_width="wrap_content"  
  12.         android:layout_alignParentRight="true"  
  13.         android:layout_centerVertical="true"  
  14.         android:background="@drawable/voice_max"/>  
  15.     <SeekBar   
  16.         android:id="@+id/sb_voice"  
  17.         android:layout_height="wrap_content"  
  18.         android:layout_width="fill_parent"  
  19.         android:layout_centerVertical="true"  
  20.         android:layout_toLeftOf="@id/voice_max"  
  21.         android:layout_toRightOf="@id/voice_min"  
  22.         android:paddingLeft="5dp"  
  23.         android:paddingRight="5dp"  
  24.         android:background="@drawable/voice_seekbar_bg"  
  25.         />  


错误就消失了,原来toLeftOf和toRightOf的参数需要在使用它们之前定义,

刚开始只想着从左到右的顺序挨个写,显得有条理,看来我想多了.

错误就消失了,
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值