zoukankan      html  css  js  c++  java
  • Android之圆角矩形

    安卓圆角矩形的定义

    在drawable文件夹下,定义corner.xml

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle">
    <!-- 填充颜色 -->
    <solid android:color="#FF8C69"></solid>
    
    <!-- 线的宽度,颜色灰色 -->
    <stroke android:width="1dp" android:color="#D5D5D5"></stroke> 
    
    <!-- 矩形的圆角半径 -->
    <corners android:radius="10dp" /> 
    
    </shape>

    具体使用

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        tools:context="${relativePackage}.${activityClass}" >
    
        <ImageView 
            android:adjustViewBounds="true"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:background="@drawable/b"
            android:padding="0dp"
    
            />
    <LinearLayout 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="horizontal"
        android:layout_weight="1"
        >
        <LinearLayout
            android:id="@+id/l1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_margin="3dp"
            android:layout_marginBottom="5dp"
            android:layout_weight="1"
            android:background="@drawable/corner"
            android:gravity="center"
            android:orientation="horizontal" >
    
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:text="二手市场" />
        </LinearLayout>
    
        <LinearLayout
            android:id="@+id/l2"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_margin="3dp"
            android:layout_weight="1"
            android:background="@drawable/corner2"
            android:gravity="center"
            android:orientation="horizontal" >
    
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:gravity="center"
                android:text="失物招领" />
        </LinearLayout>
    </LinearLayout>
    
    <LinearLayout 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="horizontal"
        android:layout_weight="1"
        >
        <LinearLayout 
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:orientation="vertical"
    
            >
            <LinearLayout
            android:id="@+id/l3"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
    
            android:layout_margin="3dp"
            android:layout_weight="1"
            android:background="@drawable/corner3"
            android:gravity="center"
            android:orientation="horizontal" >
    
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:gravity="center"
                android:text="寻物启事" />
        </LinearLayout>
        <LinearLayout
    
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_margin="3dp"
            android:layout_weight="1"
            android:background="@drawable/corner4"
            android:gravity="center"
            android:orientation="horizontal" >
    
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:gravity="center"
                android:text="表白墙" />
        </LinearLayout>
        </LinearLayout>
        <LinearLayout 
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:orientation="horizontal"
            >
            <LinearLayout
    
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_margin="3dp"
            android:layout_weight="1"
            android:background="@drawable/corner5"
            android:gravity="center"
            android:orientation="horizontal" >
    
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:gravity="center"
                android:text="生活查询" />
        </LinearLayout>
        <LinearLayout
    
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_margin="3dp"
            android:layout_weight="1"
            android:background="@drawable/corner6"
            android:gravity="center"
            android:orientation="horizontal" >
    
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:gravity="center"
                android:text="校园查询" />
        </LinearLayout>
    
        </LinearLayout>
    </LinearLayout>
    </LinearLayout>

    参考链接

    android 怎么画一个圆角矩形_百度知道

    效果如下

    这里写图片描述

  • 相关阅读:
    HDU 2433 Travel (最短路,BFS,变形)
    HDU 2544 最短路 (最短路,spfa)
    HDU 2063 过山车 (最大匹配,匈牙利算法)
    HDU 1150 Machine Schedule (最小覆盖,匈牙利算法)
    290 Word Pattern 单词模式
    289 Game of Life 生命的游戏
    287 Find the Duplicate Number 寻找重复数
    283 Move Zeroes 移动零
    282 Expression Add Operators 给表达式添加运算符
    279 Perfect Squares 完美平方数
  • 原文地址:https://www.cnblogs.com/jjx2013/p/6223670.html
Copyright © 2011-2022 走看看