How to remove excess space from the menu

enter image description here I am new to Android and use the overflow menu in my program,

I need to know a few things:

Question 1: How to remove excess empty space in the settings, for example, in: Video, Email

Question 2: Want to hide the name and title of the application and ICON from FirstActivity

Check out my code below

Menu > items.xml:

<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/phone" android:title="@string/phone" android:icon="@drawable/phone" android:showAsAction="ifRoom|withText" /> <item android:id="@+id/computer" android:title="@string/computer" android:icon="@drawable/computer" android:showAsAction="ifRoom|withText" /> <item android:id="@+id/gamepad" android:title="@string/gamepad" android:icon="@drawable/gamepad" android:showAsAction="ifRoom|withText" /> <item android:id="@+id/camera" android:title="@string/camera" android:icon="@drawable/camera" android:showAsAction="ifRoom|withText" /> <item android:id="@+id/video" android:title="@string/video" android:icon="@drawable/video" android:showAsAction="ifRoom|withText" /> <item android:id="@+id/email" android:title="@string/email" android:icon="@drawable/email" android:showAsAction="ifRoom|withText" /> </menu> 

Manifest.xml:

  <application android:icon="@drawable/ic_launcher" android:uiOptions="splitActionBarWhenNarrow" android:allowBackup="true" > <activity android:name="com.sample.menu.HomeActivity" android:label="Demo App" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="com.sample.menu.FirstActivity" android:label="First Activity"> <intent-filter> <action android:name="com.sample.menu.second" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> </application> 

FirstActivity.java:

  public class FirstActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); getActionBar().setDisplayHomeAsUpEnabled(true); setContentView(R.layout.activity_first); getOverflowMenu(); } 
+4
source share
3 answers

for your Question 2: in onCreate ()

 this.requestWindowFeature(Window.FEATURE_NO_TITLE); 

to make the action bar icon transparent

 getActionBar().setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent))); 

in Manifest.xml

 <android:theme="@android:style/Theme.NoTitleBar"> 

For your question 1:

this link is useful for you

0
source

For question 2 add

 requestWindowFeature(Window.FEATURE_NO_TITLE); 

Right before:

 setContentView(R.layout.activity_first); 
0
source

In full screen mode

 super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.my_layout); 

FOR RESET MENU, please specify what you need ...?

0
source

Source: https://habr.com/ru/post/1502731/


All Articles