Android ActionBar Item max width -
Android ActionBar Item max width -
i'm trying show 3 things on menu: app's icon, spinner, , button. problem is, spinne takes much space, hiding button (which of import users).
in first image can see button on right (mail-like icon), shown when manually set spinner's width 60dp (which not want, app might used tablets , phones). can see, in sec image spinner taking space, hiding button.
here's code of activity_main.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" tools:context="com.androidinit.activitymain" > <item android:id="@+id/institution_selector" android:showasaction="always|withtext" android:title="@string/empty_string"/> <item android:id="@+id/institution_spinner" android:showasaction="always|withtext" android:title="@string/no_institution" android:actionlayout="@layout/ppn_institution_spinner_menu" /> <item android:id="@+id/send_message_teacher_main_button" android:orderincategory="100" android:showasaction="always|withtext" android:icon="@drawable/icon_message" android:title="@string/send_message_teacher_main"/> what set "weight" spinner, should width of screen - icon - button, haven't been able this. i've followed lots of tutorials, can't work.
something has been bothering me can't alter .xml relativelayout, seen on many tutorials, illustration one: android developers myfirstapp - "menu cannot resolved or not field" each time seek "deleting xml"
<menu xmlns:android="http://schemas.android.com/apk/res/android"></menu> is autogenerated eclipse (forcing me have "menu"). hope i'm missing something, because have been going through hours, still nothing.
lets this.. taking space because of length of text or items hack it.. this
yourspinner.setgravity(gravity.start); or
yourspinner.setscalex((float)0.2); //choose preferred decimal or
layoutparams layoutparams = (linearlayout.layoutparams) yourspinner.getlayoutparams(); layoutparams.width = (yourspinner. getwidth()%2); yourspinner.setlayoutparams(layoutparams); the lastly 1 might promising..
maybe might help shrink spinner in actionbar
note: wild guess functionality..
let me know if helps
android android-layout android-actionbar android-xml
Comments
Post a Comment