On Android M
button.setText("✔");
button.setTextColor(Color.WHITE);
Does not work any idea why?
How can i get the ✔ white colored?
On Android M
button.setText("✔");
button.setTextColor(Color.WHITE);
Does not work any idea why?
How can i get the ✔ white colored?
try doing this way,
in your xml file,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="@+id/btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@mipmap/ic_launcher"
android:hint="hii" />
</LinearLayout >
Now, in your java file add this code like
public class SixthActivity extends AppCompatActivity {
Button btn;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.first_activity);
btn = (Button) findViewById(R.id.btn);
btn.setText("");
btn.setBackgroundColor(getResources().getColor(R.color.white));
btn.setBackgroundResource(R.mipmap.ic_launcher);
}
}
Actually you can add drawables to view. Like that in xml :
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Load More"
android:id="@+id/loadMore"
android:drawableLeft="@drawable/your_marked_icon"
android:drawableRight="@drawable/another_icon_if_need"
style="?android:attr/borderlessButtonStyle"
android:layout_centerHorizontal="true" />
Also in your code you can do like that :
Drawable top = getResources().getDrawable(R.drawable.image);
//placement is like that : left, top, right, bottom
button.setCompoundDrawablesWithIntrinsicBounds(null, top , null, null);
I take this solution in : How to set property “android:drawableTop” of a button at runtime
Also you can change drawable's tint value like that:
public static Drawable setTint(Drawable d, int color) {
Drawable wrappedDrawable = DrawableCompat.wrap(d);
DrawableCompat.setTint(wrappedDrawable, color);
return wrappedDrawable;
}
this solution based on : change color of drawable
You can use unicode also for tick mark,Try to use ✓
with string and set it to your textview.