나는 이것을 시도하지 않았고, 당신이 말하는 버튼을 본 적이 없다. 그러나 그 과정은 비슷한 것이어야합니다.
먼저 드로어 블 (실제 배경 이미지)을 만듭니다. 하나는 빨간색 배경과 하나는 투명합니다. 귀하의 당김 XML은 다음과 같이 보일 것입니다 :
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/btn_bg_red"/>
<item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/btn_bg_red"/>
<item android:state_focused="true" android:drawable="@drawable/btn_bg_pressed"/>
<item android:state_focused="false" android:state_pressed="false" android:drawable="@android:color/transparent"/>
</selector>
이 그런 다음 버튼 자체가 이와 유사한 선언 할 수 있습니다 :
<Button android:id="@+id/droid_x_btn"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Droid Does"
android:drawableTop="@drawable/btn_icon" <!-- this is for the icon on top -->
android:background="@drawable/ic_droid_x_button" <!-- The name of the above file without extension -->
android:textColor="@color/white" />
희망이 도움이!
흠, 그게 내가 가진 것과 거의 똑같아.하지만 네가 더 우아 해. 텍스트 뒤에있는 검정색 막대는 조정할 수없는 경우에도 솔루션으로 작동 할 것입니다. 대단히 감사합니다. :) – Joshua