반응형
클릭 가능한 ImageView와 ImageButton의 차이점
ImageView
클릭 가능한 것으로 설정되어있는 사이 에 ImageButton
? 와 비교하여 중요한 차이점이 있는지 궁금 합니다 .
다른 것을 사용하는 이유가 있습니까? 유일한 옵션으로 ImageButton
남겨 ImageView
지는 드로어 블에 대한 제한이 있습니까?
클릭 가능 광고 ImageView
를 선택하면 버튼의 기능이 손실 될 수 ImageButton
있습니까?
기본 스타일을 제외하고는 차이가 없습니다. ImageButton
기본적으로 널이 아닌 배경을 갖습니다.
편집 : 또한 ImageButton.onSetAlpha()
메소드는 항상 false를 반환하고 scaleType
로 설정되며 center
항상 초점을 맞출 수 있도록 팽창됩니다.
ImageButton
기본 스타일은 다음과 같습니다 .
<style name="Widget.ImageButton">
<item name="android:focusable">true</item>
<item name="android:clickable">true</item>
<item name="android:scaleType">center</item>
<item name="android:background">@android:drawable/btn_default</item>
</style>
ImageButton은 ImageView에서 상속됩니다.
public class ImageButton extends ImageView {
public ImageButton(Context context) {
this(context, null);
}
public ImageButton(Context context, AttributeSet attrs) {
this(context, attrs, com.android.internal.R.attr.imageButtonStyle);
}
public ImageButton(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
setFocusable(true);
}
@Override
protected boolean onSetAlpha(int alpha) {
return false;
}
@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
super.onInitializeAccessibilityEvent(event);
event.setClassName(ImageButton.class.getName());
}
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info);
info.setClassName(ImageButton.class.getName());
}
@ Micheal이 설명 한대로 나는 그의 대답에 세부 사항을 추가합니다.
클릭 할 때 버튼 클릭의 효과는 imagebutton에는 있지만 imageView에는 없습니다.
참고 URL : https://stackoverflow.com/questions/5847136/difference-between-a-clickable-imageview-and-imagebutton
반응형
'IT' 카테고리의 다른 글
파이썬에서 튜플 비교는 어떻게 작동합니까? (0) | 2020.06.21 |
---|---|
TargetedPatchingOptOut : "NGen 이미지 경계를 가로 질러 인라인하는 데 중요한 성능"? (0) | 2020.06.21 |
gitignore 제외 규칙은 실제로 어떻게 작동합니까? (0) | 2020.06.21 |
리눅스에서 주어진 크기로 파일을 만드는 방법? (0) | 2020.06.19 |
모든 사용자를 위해 Linux에서 JAVA_HOME을 설정하는 방법 (0) | 2020.06.19 |