I placed a spinner inside TableRow in TableLayout. Spinner dropdown icon not visible.
Table 1: I place a spinner inside table row, But my spinner dropdown arrow not visible inside table row
Table 2: I have placed spinner inside Relative Layout which is inside Table Row, In this scenario also spinner drop down not visible and in UI screen spinner width exceed Relative Layout.
How can I fix the spinner fixed into the width with drop down icon visible?What's wrong with below code.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TableLayout
android:layout_height="wrap_content"
android:layout_width="match_parent">
<TableRow style="@style/HeaderRow"
android:weightSum="10">
<ImageView
android:layout_width="0dp"
android:layout_weight="1"
android:src="@drawable/ic_info_white"
style="@style/HeaderText" />
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="5" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="Information"
android:paddingLeft="@dimen/ten"
android:textColor="@color/color_white"/>
</RelativeLayout>
<ImageView
android:layout_width="0dp"
style="@style/HeaderText"
android:src="@drawable/ic_info_white"
android:layout_weight="1" />
<Spinner
android:layout_width="0dp"
android:layout_weight="4"
android:layout_height="match_parent" />
</TableRow>
</TableLayout>
<TableLayout
android:layout_height="wrap_content"
android:layout_width="match_parent">
<TableRow style="@style/HeaderRow"
android:weightSum="10">
<ImageView
android:layout_width="0dp"
android:layout_weight="1"
android:src="@drawable/ic_info_white"
style="@style/HeaderText" />
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="5" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="Information"
android:paddingLeft="@dimen/ten"
android:textColor="@color/color_white"/>
</RelativeLayout>
<ImageView
android:layout_width="0dp"
style="@style/HeaderText"
android:src="@drawable/ic_info_white"
android:layout_weight="1" />
<RelativeLayout
android:layout_width="0dp"
android:layout_weight="4"
android:layout_height="match_parent" >
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</RelativeLayout>
</TableRow>
</TableLayout>
</LinearLayout>
Style.xml
<style name="HeaderRow">
<item name="android:background">#A3A3A3</item>
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">match_parent</item>
</style>
<style name="HeaderText">
<item name="android:textColor">@color/color_white</item>
<item name="android:shadowColor">#AFFFFFFF</item>
<item name="android:shadowDx">1</item>
<item name="android:shadowDy">1</item>
<item name="android:shadowRadius">1.0</item>
<item name="android:padding">5dp</item>
<item name="android:gravity">center</item>
<item name="android:textSize">14sp</item>
<item name="android:textStyle">bold</item>
<item name="android:background">@drawable/border</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">match_parent</item>
</style>
As you have added TableRow
weightsum
value as 10 then all child views layout_weight
values sum should also be 10.
For example;
<TableRow
style="@style/HeaderRow"
android:weightSum="10">
<ImageView
style="@style/HeaderText"
android:layout_width="0dp"
android:layout_weight="1" />
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:paddingLeft="10dp"
android:text="Information"
android:textColor="#FFFFFF" />
</RelativeLayout>
<ImageView
style="@style/HeaderText"
android:layout_width="0dp"
android:layout_weight="1" />
<Spinner
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4" />
</TableRow>