通过在drawble下定义xml实现圆角边

没事随便写写!需要用到圆角矩形边框,通过在drawble文件定义shape.xml实现;
不多说,直接上代码:
shape_round_corner.xml

//定义四个圆角<shape xmlns:android="http://schemas.android.com/apk/res/android">    <solid android:color="#ff00" />    <corners android:topLeftRadius="12dp"        android:topRightRadius="12dp"        android:bottomRightRadius="12dp"        android:bottomLeftRadius="12dp"/>    <stroke android:width="1dp" android:color="#ff0" />shape><shape xmlns:android="http://schemas.android.com/apk/res/android">    <solid android:color="#ff00" />    <corners android:topLeftRadius="12dp"        android:topRightRadius="12dp"        />    <stroke android:width="1dp" android:color="#ff0" />shape>

activity_main.xml

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="vertical">    <LinearLayout        android:layout_width="300dp"        android:layout_height="300dp"        android:layout_marginBottom="10dp"        android:layout_marginLeft="10dp"        android:layout_marginRight="10dp"        android:layout_marginTop="10dp"        android:alpha="0.8"        android:background="@drawable/shape_round_corner">    LinearLayout>LinearLayout>

MainActivity.java

public class MainActivity extends Activity {    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);    }}

附属上一张图片:

更多相关文章

  1. Android的Master/Detail风格界面中实现自定义ListView的单选
  2. android ImageView实现上面圆角下面直角(自定义view实现)
  3. android 桌面小部件(App Widgets)如何显示自定义的view
  4. BuildGradle自定义打包
  5. Android(安卓)draw Rect 坐标图示
  6. android中对json数据的解析,并在listview中实际运用
  7. Android:使用Canvas合并Bitmap
  8. 【Dialer】自定义暗码进入测试模式
  9. framework下资源文件---自定义统一的系统风格

随机推荐

  1. Android(安卓)实现颜色渐变的一个小 tip
  2. Android(安卓)DataBinding 找不到生成的b
  3. Android创建文件夹
  4. Android瀑布流的实现
  5. Android(安卓)xmlns 的作用及其自定义
  6. Android(安卓)Studio 1.0 (稳定版) 完全
  7. [Android] 该文件包与具有同一名称的现有
  8. Android开发(九)| android手势开发
  9. design principle:模拟 android Button 控
  10. Android多分辨率适配