#Android如何设置控件圆角:

#Android如何设置控件圆角:

1. res目录下的drawable目录下新建shape.xml文件。
<?xml version="1.0" encoding="utf-8"?>  
<shape xmlns:android="http://schemas.android.com/apk/res/android"  
    android:shape="rectangle" >  
    <!-- 填充的颜色 -->  
    <solid android:color="#FF065E8D" />  
    <!-- 设置按钮的四个角为弧形 -->  
    <!-- android:radius 弧形的半径 -->  
    <corners android:radius="15dip" />  
    <!-- padding:Button里面的文字与Button边界的间隔 -->  
    <padding  
        android:bottom="10dp"  
        android:left="10dp"  
        android:right="10dp"  
        android:top="10dp" />  
</shape>  
2.在布局文件中调用。
<?xml version="1.0" encoding="utf-8"?>  
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
    android:layout_width="fill_parent"  
    android:layout_height="fill_parent"  
    android:orientation="vertical" >  
    <Button  
        android:id="@+id/roundButton"  
        android:layout_width="wrap_content"  
        android:layout_height="wrap_content"  
        android:background="@drawable/shape"  
        android:text="圆角按钮" />  
</LinearLayout>  
#Android图片加载框架Glide的基本用法:
1.新建一个GlideTest项目,然后在app/build.gradle文件当中添加如下依赖:
implementation 'com.github.bumptech.glide:glide:4.1.0'
2.在MainActivity中添加:
import com.bumptech.glide.Glide;
//        不加下面这句App将打不开!!!
        imageView = (ImageView) findViewById(R.id.image_view);
//        加载网络图片
//        public void loadImage(View view){
//        String url = "url图片地址";
//        Glide.with(this).load(url).into(imageView);
//    }
3.在_layout.xml中添加Button的点击事件。
//        定义鼠标点击事件
        Button button = (Button)findViewById(R.id.button);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                在此处添加逻辑
            }
        });
//        定义鼠标点击事件
4.Androidstudio中资源文件<图片>不能用中文或大写英文字母命名!




猜你喜欢

转载自blog.csdn.net/iversons/article/details/79199000