Issue
I am trying to setup style for Button, but from some unknown reasons attribute "background" from style is not applying. I want achieve a transparent rectangle button over arrow that is on lower layer.
I created style ButtonMorse:
<style name="ButtonMorse" parent="Widget.AppCompat.Button">
<item name="android:layout_width">30dp</item>
<item name="android:layout_height">30dp</item>
<item name="background">@color/transparent</item>
<item name="backgroundColor">@color/transparent</item>
</style>
For comparison 1st button background attribute is set directly, not using style (works fine).
Layout code:
<Button
android:id="@+id/buttonUp0"
android:layout_marginStart="525dp"
android:layout_marginTop="420dp"
android:onClick="buttonUp0Click"
android:layout_width="30dp"
android:layout_height="30dp"
android:background="@color/transparent"/>
<TextView
style="@style/CharacterMorseTextView"
android:id="@+id/character0"
android:layout_marginStart="522dp"
android:layout_marginTop="450dp" />
<Button
style="@style/ButtonMorse"
android:id="@+id/buttonDown0"
android:layout_marginStart="525dp"
android:layout_marginTop="525dp"
android:onClick="buttonDown0Click"/>
Color:
<color name="transparent">#00000000</color>
Result: Result on emulator
Solution
As Ananta commented - there was mistake in my style file. It should be:
<item name="android:background">@color/transparent</item>
instead of:
<item name="background">@color/transparent</item>
Question closed.
Answered By - Grzanek
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.