android:id="@id/view01"错在哪?哪??哪???

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
     >
    
    <!--定义该组件位于父容器中间  -->
    <TextView
        android:id="@id/view01"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        
        android:background="@drawable/leaf"
        android:layout_centerInParent="true"
        />
    
    <!-- 定义该图view02在第一个图view01的上边,与图view01的左边界对齐 -->
    <TextView
        android:id="@id/view02"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/leaf"
        android:layout_above="@id/view01" 
        android:layout_alignLeft="@+id/view01"
        />
    
    <!-- 定义该图view03在第一个图view01的下边,与图view01的左边界对齐 -->
    <TextView
        android:id="@id/view03"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/leaf"
        android:layout_below="@id/view01" 
        android:layout_alignLeft="@+id/view01"
        />
    
    <!-- 定义该图view04在第一个图view01的左边,与图view01的上边界对齐 -->
    <TextView
        android:id="@id/view04"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/leaf"
        android:layout_toLeftOf="@id/view01" 
        android:layout_alignTop="@+id/view01"
        />
    
     <!-- 定义该图view05在第一个图view01的右边,与图view01的上边界对齐 -->
    <TextView
        android:id="@id/view05"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/leaf"
        android:layout_toRightOf="@id/view01" 
        android:layout_alignTop="@+id/view01"
        />
    
    

</RelativeLayout></span></strong>


为了达到梅花效果,一顿的调,一顿的调, android:id="@id/view01"这句话总是报错,gen/R.java中的id类里边总是加不上去view01到view05这几个变量。不是第一次了,对这个有点迟钝,“+”,切记,切记!!!正确的是这样:android:id="@+id/view01"

正确的代码:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
     >
    
    <!--定义该组件位于父容器中间  -->
    <TextView
        android:id="@+id/view01"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        
        android:background="@drawable/leaf"
        android:layout_centerInParent="true"
        />
    
    <!-- 定义该图view02在第一个图view01的上边,与图view01的左边界对齐 -->
    <TextView
        android:id="@+id/view02"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/leaf"
        android:layout_above="@id/view01" 
        android:layout_alignLeft="@+id/view01"
        />
    
    <!-- 定义该图view03在第一个图view01的下边,与图view01的左边界对齐 -->
    <TextView
        android:id="@+id/view03"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/leaf"
        android:layout_below="@id/view01" 
        android:layout_alignLeft="@+id/view01"
        />
    
    <!-- 定义该图view04在第一个图view01的左边,与图view01的上边界对齐 -->
    <TextView
        android:id="@+id/view04"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/leaf"
        android:layout_toLeftOf="@id/view01" 
        android:layout_alignTop="@+id/view01"
        />
    
     <!-- 定义该图view05在第一个图view01的右边,与图view01的上边界对齐 -->
    <TextView
        android:id="@+id/view05"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/leaf"
        android:layout_toRightOf="@id/view01" 
        android:layout_alignTop="@+id/view01"
        />
    
    

</RelativeLayout>


 

 

  • 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、付费专栏及课程。

余额充值