### Login Form using Shape Components Source: https://context7.com/getactivity/shapeview/llms.txt This comprehensive example demonstrates integrating various ShapeView components, including ShapeLinearLayout, ShapeEditText, ShapeButton, and ShapeCheckBox, to create a styled login form. ```xml ``` -------------------------------- ### XML: Gradient Background ConstraintLayout Source: https://context7.com/getactivity/shapeview/llms.txt Define a ConstraintLayout with a gradient background using XML attributes. Specify start color, end color, and orientation. ```xml ``` -------------------------------- ### Enable AndroidX Support Source: https://github.com/getactivity/shapeview/blob/master/README.md Add these properties to your project's gradle.properties file to ensure compatibility with AndroidX libraries. ```text # 表示使用 AndroidX android.useAndroidX = true # 表示将第三方库迁移到 AndroidX android.enableJetifier = true ``` -------------------------------- ### Configure JitPack Repository (Gradle < 7.0) Source: https://github.com/getactivity/shapeview/blob/master/README.md Add this to your project's build.gradle file if using Gradle version below 7.0 to include the JitPack repository. ```groovy allprojects { repositories { // JitPack 远程仓库:https://jitpack.io maven { url 'https://jitpack.io' } } } ``` -------------------------------- ### Configure JitPack Repository (Gradle >= 7.0) Source: https://github.com/getactivity/shapeview/blob/master/README.md Add this to your settings.gradle file if using Gradle version 7.0 or above to include the JitPack repository. ```groovy dependencyResolutionManagement { repositories { // JitPack 远程仓库:https://jitpack.io maven { url 'https://jitpack.io' } } } ``` -------------------------------- ### Integrate ShapeView Framework Source: https://context7.com/getactivity/shapeview/llms.txt Configure JitPack repository and add ShapeView and ShapeDrawable dependencies. Ensure AndroidX and Jetifier are enabled in gradle.properties. ```groovy settings.gradle(Gradle 7.0+) dependencyResolutionManagement { repositories { maven { url 'https://jitpack.io' } } } // app/build.gradle android { compileOptions { targetCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8 } } dependencies { implementation 'com.github.getActivity:ShapeView:10.0' implementation 'com.github.getActivity:ShapeDrawable:3.3' } // gradle.properties(AndroidX 项目必须) android.useAndroidX=true android.enableJetifier=true ``` -------------------------------- ### Java: Dynamic Dashed Border EditText Configuration Source: https://context7.com/getactivity/shapeview/llms.txt Dynamically configure an EditText with a dashed border using Java code. Requires setting stroke dash size and gap. ```java // Java 代码动态配置带虚线边框的输入框 ShapeEditText et = findViewById(R.id.et_input); et.getShapeDrawableBuilder() .setSolidColor(0xFFF5F5F5) .setRadius(8f) .setStrokeColor(0xFF5A8DDF) .setStrokeSize(2) .setStrokeDashSize(6) // 虚线段长度(大于 0 则为虚线) .setStrokeDashGap(4) // 虚线间隔 .intoBackground(); // 虚线/阴影会自动关闭硬件加速 ``` -------------------------------- ### Ring ShapeView with Inner Radius and Thickness Source: https://context7.com/getactivity/shapeview/llms.txt Implement a ring ShapeView by setting shape_type to 'ring'. Control its appearance using inner radius and thickness ratios. ```xml ``` -------------------------------- ### Line ShapeView with Stroke and Gravity Source: https://context7.com/getactivity/shapeview/llms.txt Create a line ShapeView using shape_type='line'. Customize its appearance with stroke color, size, dash patterns, and gravity. ```xml ``` -------------------------------- ### Java: Dynamic Ring Shape ImageView Background Source: https://context7.com/getactivity/shapeview/llms.txt Dynamically change the background of a ShapeImageView to a ring shape using Java code. Adjust inner radius and thickness ratios. ```java // Java 代码动态改变背景为圆环形状 ShapeImageView iv = findViewById(R.id.iv_avatar); iv.getShapeDrawableBuilder() .setType(ShapeType.RING) .setRingInnerRadiusRatio(2.5f) // 内环半径比率(整环 / ratio = 内径) .setRingThicknessRatio(10f) // 外环厚度比率 .setSolidColor(0xFF5A8DDF) .intoBackground(); ``` -------------------------------- ### Java: Dynamic Card Container Background Update Source: https://context7.com/getactivity/shapeview/llms.txt Dynamically update the background of a card-like container (ShapeLinearLayout) using Java code. Allows modification of radius, colors, stroke, and shadow properties. ```java // Java 代码中动态修改卡片容器背景 ShapeLinearLayout card = findViewById(R.id.ll_card); card.getShapeDrawableBuilder() .setRadius(12f) .setSolidColor(0xFFF0F4FF) .setStrokeColor(0xFFB0C4FF) .setStrokeSize(1) .setShadowSize(12) .setShadowColor(0x1A5A8DDF) .setShadowOffsetY(6) .intoBackground(); ``` -------------------------------- ### Add ShapeView and ShapeDrawable Dependencies Source: https://github.com/getactivity/shapeview/blob/master/README.md Include these dependencies in your app module's build.gradle file to use ShapeView and ShapeDrawable. Ensure JDK 1.8 compatibility is set. ```groovy android { // 支持 JDK 1.8 compileOptions { targetCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8 } } dependencies { // ShapeView:https://github.com/getActivity/ShapeView implementation 'com.github.getActivity:ShapeView:10.0' // ShapeDrawable:https://github.com/getActivity/ShapeDrawable implementation 'com.github.getActivity:ShapeDrawable:3.3' } ``` -------------------------------- ### XML: Shadowed Rounded Card LinearLayout Source: https://context7.com/getactivity/shapeview/llms.txt Create a LinearLayout with a shadowed, rounded card appearance using XML attributes. Includes radius, solid color, stroke, and shadow properties. ```xml ``` -------------------------------- ### ShapeTextView Dynamic Text Gradient and Stroke Source: https://context7.com/getactivity/shapeview/llms.txt Dynamically set text gradient colors and stroke for ShapeTextView using Java. Also demonstrates setting a radial gradient background. ```java ShapeTextView tv = findViewById(R.id.tv_title); tv.getTextColorBuilder() .setTextGradientColors(0xFFFF6B6B, 0xFF6B8CFF) // 起始、结束渐变色 .setTextGradientOrientation(TextColorBuilder.GRADIENT_ORIENTATION_HORIZONTAL) .setTextStrokeColor(0xFF333333) // 文字描边颜色 .setTextStrokeSize(2) // 文字描边宽度(px) .intoTextColor(); // 也可为背景设置径向渐变 tv.getShapeDrawableBuilder() .setSolidGradientColors(0xFFFF6B6B, 0xFFFFAA6B, 0xFF6B8CFF) // 三色渐变 .setSolidGradientType(ShapeGradientType.RADIAL_GRADIENT) .setSolidGradientRadius(200) .intoBackground(); ``` -------------------------------- ### XML: Custom Icon CheckBox with State Selectors Source: https://context7.com/getactivity/shapeview/llms.txt Define a ShapeCheckBox in XML with custom drawables for default, checked, and disabled states. Text color can also be customized per state. ```xml ``` -------------------------------- ### ShapeButton Dynamic Customization Source: https://context7.com/getactivity/shapeview/llms.txt Dynamically modify ShapeButton's background and text colors using Java code. Call `intoBackground()` and `intoTextColor()` to apply changes. ```java ShapeButton btn = findViewById(R.id.btn_submit); btn.setEnabled(true); // 修改背景形状属性后调用 intoBackground() 生效 btn.getShapeDrawableBuilder() .setSolidColor(0xFF000000) .setRadius(24f) // 统一设置四角圆角(单位 px) .setStrokeColor(0xFF5A8DDF) .setStrokeSize(2) .setShadowSize(8) .setShadowColor(0x663A6DBF) .setShadowOffsetY(4) .intoBackground(); // ⚠️ 必须调用,否则不生效 // 修改文字颜色后调用 intoTextColor() 生效 btn.getTextColorBuilder() .setTextColor(0xFFFFFFFF) .setTextPressedColor(0xFFCCCCCC) .intoTextColor(); // ⚠️ 必须调用,否则不生效 btn.setText("已提交"); ``` -------------------------------- ### XML: Circular Background ImageView Source: https://context7.com/getactivity/shapeview/llms.txt Define a ShapeImageView with a circular background in XML, suitable for avatar placeholders. ```xml ``` -------------------------------- ### Dynamically Change ShapeButton Appearance Source: https://github.com/getactivity/shapeview/blob/master/README.md This Java code snippet demonstrates how to dynamically change the solid color, stroke color, and text color of a ShapeButton at runtime. Remember to call `intoBackground()` and `intoTextColor()` to apply the changes. ```java ShapeButton shapeButton = findViewById(R.id.btn_main_test); shapeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { shapeButton.getShapeDrawableBuilder() .setSolidColor(0xFF000000) .setStrokeColor(0xFF5A8DDF) // 注意:最后需要调用一下 intoBackground 方法才能生效 .intoBackground(); shapeButton.getTextColorBuilder() .setTextColor(0xFFFFFFFF) // 注意:最后需要调用一下 intoTextColor 方法才能生效 .intoTextColor(); shapeButton.setText("颜色已经改变啦"); } }); ``` -------------------------------- ### ShapeTextView XML Declaration Source: https://context7.com/getactivity/shapeview/llms.txt Declare a ShapeTextView in XML with attributes for gradient background and gradient text colors, including orientation. ```xml ``` -------------------------------- ### Java: Dynamic CheckBox Button Drawable State Update Source: https://context7.com/getactivity/shapeview/llms.txt Dynamically update the button drawables (icons) for a ShapeCheckBox's different states using Java code. Ensure 'intoButtonDrawable()' is called for changes to take effect. ```java // Java 代码动态更新 CheckBox 选中图标状态 ShapeCheckBox cb = findViewById(R.id.cb_agree); cb.getButtonDrawableBuilder() .setButtonDrawable(ContextCompat.getDrawable(this, R.drawable.checkbox_normal_ic)) .setButtonCheckedDrawable(ContextCompat.getDrawable(this, R.drawable.checkbox_checked_ic)) .setButtonDisabledDrawable(ContextCompat.getDrawable(this, R.drawable.checkbox_disable_ic)) .intoButtonDrawable(); // ⚠️ 必须调用,否则图标不生效 cb.setChecked(true); ``` -------------------------------- ### Rectangle ShapeView with Rounded Corners Source: https://context7.com/getactivity/shapeview/llms.txt Use this snippet for default rectangle shapes with customizable rounded corners. Ensure the shape_type attribute is set to 'rectangle'. ```xml ``` -------------------------------- ### ShapeButton XML Declaration Source: https://context7.com/getactivity/shapeview/llms.txt Declare a ShapeButton in XML with attributes for shape type, radius, solid color, pressed/disabled colors, stroke, shadow, and text colors. ```xml ``` -------------------------------- ### XML: Rounded Border EditText with Focus Color Change Source: https://context7.com/getactivity/shapeview/llms.txt Define a rounded border EditText in XML. The border color automatically changes when the input field gains focus. ```xml ``` -------------------------------- ### Oval ShapeView Source: https://context7.com/getactivity/shapeview/llms.txt Configure an oval ShapeView by setting the shape_type attribute to 'oval'. This is suitable for circular or elliptical elements. ```xml ``` -------------------------------- ### ShapeView Gradient Orientation Enum Values (v9.0) Source: https://github.com/getactivity/shapeview/blob/master/Adaptive.md Enum values for defining gradient orientation in ShapeView, used for solid color gradients. These values map to specific angles and directions for drawing gradients. ```xml ``` -------------------------------- ### ShapeView Gradient Orientation Enum Values (v9.3) Source: https://github.com/getactivity/shapeview/blob/master/Adaptive.md Enum values for defining gradient orientation in ShapeView, used for stroke gradients. These values specify directions like left-to-right, right-to-left, and diagonal gradients. ```xml ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.