一键导入
android-button-touch-strategy
Choose whether the outer container acts as the touch proxy or remains a layout placeholder to control hit targets.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Choose whether the outer container acts as the touch proxy or remains a layout placeholder to control hit targets.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | Android Button Touch Strategy |
| description | Choose whether the outer container acts as the touch proxy or remains a layout placeholder to control hit targets. |
| last_verified | "2026-01-23T00:00:00.000Z" |
| applicable_sdk | Android 14+ (API 34+) |
| dependencies | ["android-button-intent-clarification","best-practice-check"] |
Last Verified: 2026-01-23 Applicable SDK: Android 14+ (API 34+) Dependencies: android-button-intent-clarification, best-practice-check
Choose the correct interaction strategy when a visual element sits inside a larger layout container. This prevents accidental touches and clarifies whether the outer shell should act as a touch proxy or remain a layout placeholder.
Use when: You want a larger touch target for accessibility or ease of use.
Behavior:
Example:
<FrameLayout
android:id="@+id/buttonContainer"
android:layout_width="64dp"
android:layout_height="64dp"
android:background="@android:color/transparent">
<FrameLayout
android:id="@+id/buttonInner"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="center"
android:background="@drawable/shape_circle" />
</FrameLayout>
binding.buttonContainer.setOnClickListener { /* action */ }
Use when: You want alignment only and must prevent accidental touches in the transparent area.
Behavior:
Required XML:
<FrameLayout
android:id="@+id/buttonContainer"
android:layout_width="64dp"
android:layout_height="64dp"
android:background="@android:color/transparent"
android:clickable="false"
android:focusable="false">
<FrameLayout
android:id="@+id/buttonInner"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="center"
android:background="@drawable/shape_circle"
android:clickable="true"
android:focusable="true">
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center" />
</FrameLayout>
</FrameLayout>
Required Kotlin:
binding.buttonInner.setOnClickListener { /* action */ }
binding.buttonContainer.isClickable = false
Note: duplicateParentState="true" is unnecessary because the outer container
never owns interaction state in this strategy.
| Goal | Choose |
|---|---|
| Prevent mis-taps in transparent area | Strategy B |
| Maximize touch tolerance | Strategy A |
| Outer view is only for alignment | Strategy B |
| Accessibility requires larger hitbox | Strategy A |
If your core requirement is "prevent touches in the transparent area" or "outer shell is for layout alignment only":
clickable="false", inner clickable="true"setOnClickListener to binding.buttonInnerduplicateParentState="true"Guidance for creating effective modular skills for Claude. Use when creating or refining skills to ensure they are concise, follow progressive disclosure patterns, and provide appropriate degrees of freedom.
Guidelines for ensuring smooth and race-condition-free theme transitions in Android, specifically regarding icon tinting and state management.
Best practices for effective human-AI pair programming and communication
Clarify touch-target vs visual size when users ask to resize buttons without changing icons.
Best practices for 60fps custom View rendering with zero allocation in onDraw
Expert guidance for creating soulful, industrial-grade Android native interfaces with Jetpack Compose, focusing on tactility, typography, and motion.