I use simple menu items in the action bar, using the following code in the main action:
package com.kaasib.ftpclient; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.app.ActionBar; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item){ boolean ret; if(item.getItemId() == R.id.connection_manager){ ret = true; }else{ ret = super.onOptionsItemSelected(item); } return ret; } }
Here is the xml menu in main.xml:
<menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/connection_manager" android:orderInCategory="100" android:showAsAction="collapseActionView" android:title="@string/connection_manager" android:textSize="2sp" /> </menu>
It works, except that it does not change the size of the text. Right now the text size for the menu item is larger and the font size is smaller. So what am I doing wrong? Shouldn't android:textSize attribute work? Or is there another way to do this? I believe that the text size should be set from XML, not from java, as this is related to design. Any suggestion?
android android-layout android-menu
Hafiz
source share