이 질문에 대해 설명하는 제목을 부여하기가 어려웠습니다.클릭 가능한 다른보기 아래에있는보기를 클릭 가능하게 만드는 방법은 무엇입니까?
저는 현재 크기로 탭하기 어려운 일부 클릭 가능한 버튼 (앱 위젯에 필요한 RemoteViews 및 PendingIntents 사용)이있는 앱 위젯을 가지고 있습니다. 실제 버튼의 크기를 조정하지 않고이 문제를 해결하기 위해 클릭 가능한 영역을 늘리기 위해이 버튼 위에 더 크고 보이지 않는 클릭 가능한 FrameLayouts을 배치했습니다. 이것은 잘 작동합니다. 단, 버튼에 선택기가 연결되어 있기 때문에 도청시 이미지의 배경색이 변경됩니다. 이 선택기는 FrameLayout이 버튼을 덮을 때 더 이상 작동하지 않습니다. 실제로는 버튼이 아니라 실제로 탭 된 FrameLayout입니다.
내 질문에 어떻게 든 "클릭"을 통해 버튼 선택기가 계속 트리거되도록하거나 다른 똑똑한 해결 방법으로 동일한 효과를 얻는 방법이 있다면? FrameLayout 자체에 선택기를 적용하면 배경이 너무 많이 변경됩니다.
다음은 내가하는 일의 단순화 된 예입니다. 실제로 사용하는 레이아웃은 더욱 복잡하므로 레이아웃을 변경해야하는 모든 솔루션은 여기 보이는 것보다 더 어려울 수 있습니다. 또한, FrameLayout이 RelativeLayout에 배치 된 이유는 배치에 대한 자유가 더 많기 때문입니다.
FrameLayout이 편집
는 단순히 버튼 아래에 배치 할 수없는 이유는 다른 두 레이아웃의 상단에 배치됩니다. 더 넓은 영역을 커버해야합니다. 이 문제를 해결하기 위해 전체 레이아웃을 다시 할 필요가 없기를 바라고 있습니다.LAYOUT
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageButton
android:layout_width="@dimen/size_myButton_w"
android:layout_height="@dimen/size_myButton_h"
android:layout_alignParentRight="true"
android:background="@drawable/selector" //NOT TRIGGERED! Covered by FrameLayout below.
android:src="@drawable/myButton" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
<!-- More stuff here! -->
</RelativeLayout>
<!-- Even more stuff here! -->
</LinearLayout>
<FrameLayout
android:layout_width="120dp"
android:layout_height="35dp"
android:layout_alignParentRight="true">
</FrameLayout>
</RelativeLayout>
SELECTOR
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@color/navy" />
<item android:state_focused="true" android:drawable="@color/white" />
<item android:drawable="@color/white" />
</selector>
좋은 생각이지만, 내 질문에 FrameLayout이 실제로 _two_ 다른 레이아웃의 맨 위에 있다는 것을 분명히 잊어 버렸습니다. 그리고 이것들 중 하나에 넣으면 영역이 너무 작아집니다. 다른 방법이 없다면 레이아웃을 다시 시도하여 제안 할 수 있습니다. – mattboy