2016-06-27 1 views
0

터치 할 때 초점이없는 배경이있는 버튼입니다. 당신이 그것을 터치하면 변경 내용을 볼 수 있도록안드로이드에서 버튼을 눌렀을 때 배경이있는 버튼에 초점이 맞지 않는 이유는 무엇입니까?

<Button 
     android:id="@+id/continueID" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="5dp" 
     android:background="@drawable/buttonbg" 
     android:focusableInTouchMode="true" 
     android:focusable="true" 
     android:onClick="invokeLogin" 
     android:text="Login" 
     android:textColor="#F7F9FA" /> 
+0

어쩌면에 초점이 맞춰 있지만, 배경이 초점을 맞춘 상태에 대한 다른 이미지가 없습니다. –

+0

버튼을 누른 상태에서 버튼에 포커스가 있으면 액티비티 클래스를 체크 인하십시오. –

+0

기본적으로 포커스 @Akeshwar – mejkan

답변

0

'buttonbg'배경 초점을 맞춘 상태를 처리해야합니다 다음은 XML이다. 예를 들어

: -

// buttonbg.xml 

<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item android:state_focused="true" android:drawable="@drawable/your_imagename_while_focused"/> 
    <item android:state_pressed="true" android:drawable="@drawable/your_imagename_while_pressed" /> 
    <item android:drawable="@drawable/image_name_while_notpressed" /> //means normal 
</selector> 
+0

I Pressed 이미지가 없으면 어떻게해야합니까? @Omar Albelbaisy – mejkan

+0

단추를 누를 때 발생하는 변경 사항을 반영하여 배경을 설정할 때 –

+0

단추와 상호 작용할 때 표시되는 모든 상태를 구현하는 기본 단추 배경을 대체 할 수 있으므로 잡담하러 왔니? @ 오알 알벨 베르지 – mejkan

관련 문제