Android : android change button stroke color

on Saturday, August 9, 2014


I have a button that on start has a white border. This is set in the button def by applying a xml background using the following:



android:background="@drawable/butt1"


The butt1 def is as follows:



<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners
android:topLeftRadius="30dp"
android:topRightRadius="30dp"
android:bottomLeftRadius="30dp"
android:bottomRightRadius="30dp"
/>

<padding
android:left="0dp"
android:top="0dp"
android:right="0dp"
android:bottom="0dp"
/>

<stroke
android:width="4dp"
android:color="#FFFFFF"
/>
</shape>


This works fine as long as I have a dark background for the activity


My app can change backgrounds and when I change to a light background I cant see the button because of the stroke color being white (#FFFFFF)


How do I change the color of the border to say black(#000000) if the background is changed to white


I can change the text color to black using



Button view5 = (Button) findViewById(R.id.sett);
view5.setTextColor(Color.parseColor("#000000"));


but cant work out how to apply a new xml background style


Any help appreciated


mark


0 comments:

Post a Comment