android之layout_toLeftOf和layout_toRightOf出现的错误

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

大家好,又见面了,我是全栈君。

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

 

<ImageView 
	        android:id="@+id/voice_min"
	        android:layout_width="wrap_content"
	        android:layout_height="wrap_content"
	        android:layout_alignParentLeft="true"
	        android:layout_centerVertical="true"
	        android:background="@drawable/voice_min"/>
<SeekBar 
	        android:id="@+id/sb_voice"
	        android:layout_height="wrap_content"
	        android:layout_width="fill_parent"
	        android:layout_centerVertical="true"
	        android:layout_toLeftOf="@id/voice_max"
	        android:layout_toRightOf="@id/voice_min"
	        android:paddingLeft="5dp"
	        android:paddingRight="5dp"
	        android:background="@drawable/voice_seekbar_bg"
	        />
<ImageView 
	        android:id="@+id/voice_max"
	        android:layout_height="wrap_content"
	        android:layout_width="wrap_content"
	        android:layout_alignParentRight="true"
	        android:layout_centerVertical="true"
	        android:background="@drawable/voice_max"/>

 

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

 

 <ImageView 
	        android:id="@+id/voice_min"
	        android:layout_width="wrap_content"
	        android:layout_height="wrap_content"
	        android:layout_alignParentLeft="true"
	        android:layout_centerVertical="true"
	        android:background="@drawable/voice_min"/>
	    <ImageView 
	        android:id="@+id/voice_max"
	        android:layout_height="wrap_content"
	        android:layout_width="wrap_content"
	        android:layout_alignParentRight="true"
			android:layout_centerVertical="true"
	        android:background="@drawable/voice_max"/>
	    <SeekBar 
	        android:id="@+id/sb_voice"
	        android:layout_height="wrap_content"
	        android:layout_width="fill_parent"
	        android:layout_centerVertical="true"
	        android:layout_toLeftOf="@id/voice_max"
	        android:layout_toRightOf="@id/voice_min"
	        android:paddingLeft="5dp"
	        android:paddingRight="5dp"
	        android:background="@drawable/voice_seekbar_bg"
	        />

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

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

错误就消失了,

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/121449.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号