Android布局中实现圆角边框

项目结构

解析图片

每个红色正方形代表一个linklayout

每个红色圈圈代表一个imageview

每个绿色圈圈代表一个textview

他们包含关系如下


bg_boder.xml

[html]  view plain copy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <shape xmlns:android="http://schemas.android.com/apk/res/android">  
  3.     <!--背景色,我这里是白色-->  
  4.     <solid android:color="#FFFFFF" />  
  5.     <!--圆角处理-->  
  6.     <corners android:topLeftRadius="10dp"  
  7.         android:topRightRadius="10dp"  
  8.         android:bottomRightRadius="10dp"  
  9.         android:bottomLeftRadius="10dp"/>  
  10. </shape>  
在laout文件夹中加入main.xml

[html]  view plain copy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:layout_width="match_parent"  
  4.     android:layout_height="match_parent"  
  5.     android:background="#E1E0DE"  
  6.     android:orientation="vertical" >  
  7.   
  8.     <TextView  
  9.         android:id="@+id/textView1"  
  10.         android:layout_width="match_parent"  
  11.         android:layout_height="50dp"  
  12.         android:background="#2B3439"  
  13.         android:gravity="center"  
  14.         android:text="发现"  
  15.         android:textColor="#FFFFFF"  
  16.         android:textSize="20sp" />  
  17.   
  18.     <LinearLayout  
  19.         android:id="@+id/test_login_div"  
  20.         android:layout_width="fill_parent"  
  21.         android:layout_height="50dp"  
  22.         android:layout_margin="10dp"  
  23.         android:background="@drawable/bg_boder"  
  24.         android:gravity="center_vertical"  
  25.         android:padding="10dp" >  
  26.   
  27.         <ImageView  
  28.             android:id="@+id/test_imageView1"  
  29.             android:layout_width="25sp"  
  30.             android:layout_height="25sp"  
  31.             android:src="@drawable/friend" />  
  32.   
  33.         <TextView  
  34.             android:id="@+id/test_textView2"  
  35.             android:layout_width="wrap_content"  
  36.             android:layout_height="wrap_content"  
  37.             android:layout_marginLeft="14dp"  
  38.             android:text="朋友圈"  
  39.             android:textColor="#000"  
  40.             android:textSize="18sp" />  
  41.     </LinearLayout>  
  42.   
  43.     <LinearLayout  
  44.         android:layout_width="fill_parent"  
  45.         android:layout_height="101dp"  
  46.         android:layout_margin="10dp"  
  47.         android:background="@drawable/bg_boder"  
  48.         android:orientation="vertical"  
  49.         android:padding="10dp" >  
  50.   
  51.         <LinearLayout  
  52.             android:layout_width="wrap_content"  
  53.             android:layout_height="50dp" >  
  54.   
  55.             <ImageView  
  56.                 android:layout_width="25sp"  
  57.                 android:layout_height="25sp"  
  58.                 android:src="@drawable/ok" />  
  59.   
  60.             <TextView  
  61.                 android:layout_width="wrap_content"  
  62.                 android:layout_height="wrap_content"  
  63.                 android:layout_marginLeft="14dp"  
  64.                 android:text="扫一扫"  
  65.                 android:textColor="#000"  
  66.                 android:textSize="18sp" />  
  67.         </LinearLayout>  
  68.   
  69.         <LinearLayout  
  70.             android:layout_width="wrap_content"  
  71.             android:layout_height="50dp"  
  72.             android:layout_centerVertical="true" >  
  73.   
  74.             <ImageView  
  75.                 android:layout_width="25sp"  
  76.                 android:layout_height="25sp"  
  77.                 android:src="@drawable/rock" />  
  78.   
  79.             <TextView  
  80.                 android:layout_width="wrap_content"  
  81.                 android:layout_height="wrap_content"  
  82.                 android:layout_marginLeft="14dp"  
  83.                 android:text="摇一摇"  
  84.                 android:textColor="#000"  
  85.                 android:textSize="18sp" />  
  86.         </LinearLayout>  
  87.     </LinearLayout>  
  88.   
  89.     <LinearLayout  
  90.         android:layout_width="fill_parent"  
  91.         android:layout_height="101dp"  
  92.         android:layout_margin="10dp"  
  93.         android:background="@drawable/bg_boder"  
  94.         android:orientation="vertical"  
  95.         android:padding="10dp" >  
  96.   
  97.         <LinearLayout  
  98.             android:layout_width="wrap_content"  
  99.             android:layout_height="50dp" >  
  100.   
  101.             <ImageView  
  102.                 android:layout_width="25sp"  
  103.                 android:layout_height="25sp"  
  104.                 android:src="@drawable/people" />  
  105.   
  106.             <TextView  
  107.                 android:layout_width="wrap_content"  
  108.                 android:layout_height="wrap_content"  
  109.                 android:layout_marginLeft="14dp"  
  110.                 android:text="附近的人"  
  111.                 android:textColor="#000"  
  112.                 android:textSize="18sp" />  
  113.         </LinearLayout>  
  114.   
  115.         <LinearLayout  
  116.             android:layout_width="wrap_content"  
  117.             android:layout_height="50dp"  
  118.             android:layout_centerVertical="true" >  
  119.   
  120.             <ImageView  
  121.                 android:layout_width="25sp"  
  122.                 android:layout_height="25sp"  
  123.                 android:src="@drawable/bottle" />  
  124.   
  125.             <TextView  
  126.                 android:layout_width="wrap_content"  
  127.                 android:layout_height="wrap_content"  
  128.                 android:layout_marginLeft="14dp"  
  129.                 android:text="漂流瓶"  
  130.                 android:textColor="#000"  
  131.                 android:textSize="18sp" />  
  132.         </LinearLayout>  
  133.     </LinearLayout>  
  134.   
  135.     <LinearLayout  
  136.         android:id="@+id/login_div"  
  137.         android:layout_width="fill_parent"  
  138.         android:layout_height="50dp"  
  139.         android:layout_margin="10dp"  
  140.         android:background="@drawable/bg_boder"  
  141.         android:gravity="center_vertical"  
  142.         android:padding="10dp" >  
  143.   
  144.         <ImageView  
  145.             android:id="@+id/imageView1"  
  146.             android:layout_width="25sp"  
  147.             android:layout_height="25sp"  
  148.             android:src="@drawable/game_center" />  
  149.   
  150.         <TextView  
  151.             android:id="@+id/textView2"  
  152.             android:layout_width="wrap_content"  
  153.             android:layout_height="wrap_content"  
  154.             android:layout_marginLeft="14dp"  
  155.             android:text="游戏中心"  
  156.             android:textColor="#000"  
  157.             android:textSize="18sp" />  
  158.     </LinearLayout>  
  159.     </LinearLayout>  
最终效果图

Android Studio换个屏幕

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值