zoukankan      html  css  js  c++  java
  • 一手遮天 Android

    项目地址 https://github.com/webabcd/AndroidDemo
    作者 webabcd

    一手遮天 Android - view(自定义): 通过一个自定义 View 来演示 measure, layout, draw

    示例如下:

    /view/custom/CustomView1Demo.java

    /**
     * 参见 view/custom/CustomView1.java
     * 通过一个自定义 View 来演示 measure, layout, draw
     */
    
    package com.webabcd.androiddemo.view.custom;
    
    import androidx.appcompat.app.AppCompatActivity;
    import android.os.Bundle;
    
    import com.webabcd.androiddemo.R;
    
    public class CustomView1Demo extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_view_custom_customview1demo);
        }
    }
    
    

    /layout/activity_view_custom_customview1demo.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
    
        <!--
            CustomView1 - 继承 View 实现一个自定义的 View(用于演示 measure, layout, draw)
        -->
    
        <com.webabcd.androiddemo.view.custom.CustomView1
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:titleBackgroundColor="@color/red"
            app:titleColor="@color/white"
            app:titleSize="24dp"
            app:titleText="text" />
    
        <com.webabcd.androiddemo.view.custom.CustomView1
            android:layout_width="100dp"
            android:layout_height="100dp"
            app:titleBackgroundColor="@color/red"
            app:titleColor="@color/white"
            app:titleSize="24dp"
            app:titleText="text" />
    
        <com.webabcd.androiddemo.view.custom.CustomView1
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:titleBackgroundColor="@color/blue"
            app:titleColor="@color/white"
            app:titleSize="24dp"
            app:titleText="text" />
    
    </LinearLayout>
    
    

    项目地址 https://github.com/webabcd/AndroidDemo
    作者 webabcd

  • 相关阅读:
    四套读写方案
    如何保证ArrayList线程安全
    异常总结<经典例题>
    java.移位运算符
    java反射机制
    面试题:return和finally执行
    Spring_通过注解配置 Bean(1)
    Spring_通过 FactoryBean 配置 Bean
    Spring_通过工厂方法配置 Bean
    Spring_管理 Bean 的生命周期
  • 原文地址:https://www.cnblogs.com/webabcd/p/android_view_custom_CustomView1Demo.html
Copyright © 2011-2022 走看看