自定义控件的布局问题,求大神解释

胡小圣 2016-03-09 02:22:02
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<com.example.test3.MyView
android:id="@+id/myView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="你好"
android:textColor="#ff00ff00"
android:layout_below="@+id/myView" />

</RelativeLayout>
MyView是自定义控件,textView控件的layout_below="@+id/myView",自定义控件就不见了
如果自定义控件myView的layout_below="@+id/textView"又有用
原因是什么?有什么相关文章吗?
...全文
154 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
KingfarOu 2016-03-13
  • 打赏
  • 举报
回复
去掉加号不就完了,你确定你看清楚语法了
wei220000 2016-03-10
  • 打赏
  • 举报
回复
谁知道你的my view是继承的哪个控件?万一本来就没内容,不显示的呢?和+id没有一点关系,平时都那么用的。
wei220000 2016-03-10
  • 打赏
  • 举报
回复
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="20dp"
        android:text="开始"
        android:id="@+id/start_rx"/>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="30dp"
        android:layout_marginTop="10dp"
        android:textColor="@color/colorPrimaryDark"
        android:text="this will show msg"
        android:layout_below="@+id/start_rx"
        android:id="@+id/showMSG"/>
自己测试的,可以正常显示
tcmakebest 2016-03-10
  • 打赏
  • 举报
回复
应该是多打了个 + 号了.
怀君 2016-03-10
  • 打赏
  • 举报
回复
跟+号没关系,你直接运行瞅瞅。有时候在编译器里面是这样 的
keyboard3_ 2016-03-09
  • 打赏
  • 举报
回复
@+id是声明id啊,不能这么用。引用的话直接@id就行了
ESC尛蜜蜂 2016-03-09
  • 打赏
  • 举报
回复
<TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="你好" android:textColor="#ff00ff00" android:layout_below="@id/myView" /> 把加号去掉看看

80,330

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧