I need to use Spinner
with center
text with background outline.
But when I applied for Button
, it works fine. But the same when I replaced with Spinner
, the drop down is not visible and text is not center.
The below one for Button
works fine with background drawable border_grey_curve
.
<!-- <android.support.v7.widget.AppCompatButton
android:id="@+id/to_day"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.5"
android:background="@drawable/border_grey_curve"
android:drawableRight="@drawable/dropdown"
android:gravity="center"
android:paddingRight="10dp"
android:text="Kamis"
android:textAllCaps="false" />-->
But if I apply the same in Spinner
, the drop down is not coming. And also text is not centered.
Here is Spinner:
<android.support.v7.widget.AppCompatSpinner
android:id="@+id/to_day"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.5"
android:background="@drawable/border_grey_curve"
android:drawableRight="@drawable/dropdown" //applied drop down icon which is not displaying.
android:gravity="center" //not displaying text to center in spinner.
android:paddingRight="10dp"
android:text=""
android:textAllCaps="false" />
border_grey_curve.xml
:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#ffffff"/>
<corners android:radius="5dp" />
<stroke
android:width="1dp"
android:color="#d2d2d2"
/>
</shape>
</item>
</selector>
Updated full xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="5dp"
android:weightSum="5.3">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="2">
<com.customviews.CircleImageView
android:id="@+id/recycle_profile"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_marginLeft="8dp"
android:src="@drawable/ic_default_profile" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:orientation="vertical"
android:paddingLeft="3dp">
<TextView
android:id="@+id/recycle_txt_acc_num"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.25"
android:gravity="center_vertical"
android:text="12345678"
android:textColor="@color/colorBlack"
android:textSize="12sp" />
<TextView
android:id="@+id/recycle_txt_acc_name"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.5"
android:text="SE A"
android:textColor="?attr/colorUserGroup"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
<android.support.v7.widget.AppCompatButton
android:id="@+id/from_day"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.7"
android:background="@drawable/border_grey_curve"
android:gravity="center"
android:text=""
android:textAllCaps="false"
android:textColor="@color/colorBlack"
android:textSize="12sp" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_weight=".10"
android:background="@drawable/right_arrow"
android:gravity="center" />
<!-- <android.support.v7.widget.AppCompatButton
android:id="@+id/to_day"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.5"
android:background="@drawable/border_grey_curve"
android:drawableRight="@drawable/dropdown"
android:gravity="center"
android:paddingRight="10dp"
android:text="Kamis"
android:textAllCaps="false" />-->
<android.support.v7.widget.AppCompatSpinner
android:id="@+id/to_day"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.5"
android:background="@drawable/border_grey_curve"
android:drawableRight="@drawable/dropdown"
android:gravity="center"
android:paddingRight="10dp"
android:text=""
android:textAllCaps="false" />
</LinearLayout>
</RelativeLayout>