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

  • 相关阅读:
    Interesting Finds: 2009 01.15 ~ 01.17
    Interesting Finds: 2008.12.07
    Interesting Finds: 2008.12.31
    10月16号
    10月14号
    10月15号
    10月13号
    10月20号
    10月19号
    10月12号
  • 原文地址:https://www.cnblogs.com/webabcd/p/android_view_custom_CustomView1Demo.html
Copyright © 2011-2022 走看看