android - How to show my Spinner to right of Toolbar -
you can see spinner added toolbar, want make right align, show right of toolbar.
below xml code used
<linearlayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:orientation="vertical" > <android.support.v7.widget.toolbar android:id="@+id/toolbar" android:layout_height="0dp" android:layout_width="match_parent" android:layout_weight="1" android:elevation="4dp" android:gravity="right" //gravity set right android:background = "@color/color_toolbar" > <spinner android:id="@+id/spinner_category" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </android.support.v7.widget.toolbar> </linearlayout>
spinner not showing android:layout_gravity
tried setting gravity right doesn't work. how can this?
i had same issue. have fixed alignment issue based on comments of question. keeping answer here directly.
<?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionbarsize" android:minheight="?attr/actionbarsize" android:background="?attr/colorprimary"> <spinner android:id="@+id/toolbar_spinner" android:layout_width="wrap_content" android:layout_height="match_parent" android:visibility="visible" android:layout_gravity="right"/> </android.support.v7.widget.toolbar>
Comments
Post a Comment