I'm creating a custom titleBar and I'm putting some imageButtons in there, and when you set the ImageButton as default it's just gray. When you assign it a value it should completely change its view to that image.
Mine for some odd reason is setting the image correctly, but keeping the gray borders that the default ImageButton has. Is there a reason why this is?
Here's a picture of whats happening:
Here's my xml file for the titleBar:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title_activity_flash_card_display"
android:textColor="@color/bluenessText" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageButton
android:id="@+id/flashCard_show_amount_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="right" />
</LinearLayout>
</LinearLayout>
The grey box you see is actually the background. So, when you set the ImageButton
drawable, it sets the image, not the background. You can either use imageButton.setBackgroundDrawable(null);
(or imageButton.setBackground(null)
on API 16+), or instead set the background to whatever drawable you are currently using for the foreground.