I've got a Customer Spinner with images inside of it. Right now everything is working as intented except for two small things:
- The Spinner is not showing except for a small thin line.
- The Spinner Items gray border extends a bit.
I've added screenshots of these problems below:
What I want is:
- Instead of the small thin line above, I want an empty CheckBox-image like the one below it.
- At the right of the images of the Spinner items is a gray part, this should be removed.
I know both of these problems are in the xml files, but I'm kinda new to Android and I'm always a bit confused with which layout_widht/height to use when.
Here are the xml files:
activity_main.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context="com.example.testproject.MainActivity$PlaceholderFragment" >
<Spinner
android:id="@+id/spCheckbox"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:drawSelectorOnTop="true" />
<ImageButton
android:id="@+id/ibtnCheckbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:contentDescription="@string/checkbox_content_description"
android:src="@drawable/checkbox_unchecked"
android:background="@drawable/transparent_background" />
</LinearLayout>
spinner_item.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/cbImage"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:background="@drawable/transparent_button_background" />
</RelativeLayout>
(transparent_background.xml:)
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" android:drawable="@android:color/transparent" />
<item android:state_pressed="true" android:drawable="@android:color/transparent" />
<item android:drawable="@android:color/transparent" />
</selector>
So.. Which layout_width / layout_height do I need to change to get the proper results?
Thanks in advance for the responses.
EDIT: I did some research and I started by replacing all fill_parent with match_parent (since it's the same and fill_parent is deprecated after API lvl. 8). For my problem it seems my activity_main layout should be match_parent to be fullscreen and the Spinner, Spinner Item's Layout and Spinner Item's ImageView should all be wrap_content.
Still, if I change it to that, both problems still remain the same. If anyone knows how to display the selected Image of the Spinner and how to remove the gray spacing of the Spinner item, let me know.