如何从菜单中删除多余的空格

时间:2022-03-22 22:37:31

如何从菜单中删除多余的空格I am new in Android and using Overflow Menu in my program,

我是Android的新手,在我的程序中使用溢出菜单,

I need to know few things:

我需要知道一些事情:

Question 1: How to remove extra blank space in Options, like in : Video, Email

问题1:如何删除选项中的额外空白,如:视频,电子邮件

Question 2: Want to hide both Activity Name or Application Name and ICON from FirstActivity

问题2:想要从FirstActivity隐藏活动名称或应用程序名称和ICON

View my code below,

查看下面的代码,

Menu > items.xml:

菜单> 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:

的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:

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();
    }

3 个解决方案

#1


0  

For question 2 add

对于问题2添加

requestWindowFeature(Window.FEATURE_NO_TITLE);

Right before :

就在之前 :

setContentView(R.layout.activity_first);

#2


0  

To Full Screen use,

要全屏使用,

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

FOR OVERFLOW MENU, please elaborate more What u want..?

对于OVERFLOW MENU,请详细说明你想要什么..?

#3


0  

for your Question 2: in onCreate()

对于你的问题2:in onCreate()

this.requestWindowFeature(Window.FEATURE_NO_TITLE);

this is to make action bar icon transparent

这是为了使动作栏图标透明

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

in Manifest.xml

在Manifest.xml中

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

For your Question 1:

对于你的问题1:

this link is useful for you

此链接对您有用

#1


0  

For question 2 add

对于问题2添加

requestWindowFeature(Window.FEATURE_NO_TITLE);

Right before :

就在之前 :

setContentView(R.layout.activity_first);

#2


0  

To Full Screen use,

要全屏使用,

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

FOR OVERFLOW MENU, please elaborate more What u want..?

对于OVERFLOW MENU,请详细说明你想要什么..?

#3


0  

for your Question 2: in onCreate()

对于你的问题2:in onCreate()

this.requestWindowFeature(Window.FEATURE_NO_TITLE);

this is to make action bar icon transparent

这是为了使动作栏图标透明

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

in Manifest.xml

在Manifest.xml中

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

For your Question 1:

对于你的问题1:

this link is useful for you

此链接对您有用