Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何增加图标和应用程序边框之间的间距?_Android - Fatal编程技术网

Android 如何增加图标和应用程序边框之间的间距?

Android 如何增加图标和应用程序边框之间的间距?,android,Android,在扩展ActionBarActivity的活动中,我使用supportRequestWindowFeature(Window.FEATURE\u Undeterminate\u PROGRESS)和设置支持进程BarInDeterminateVibility(真)将小进度对话框显示为actionbar项目菜单 如何将更多内容分离到屏幕上 谢谢 我不知道你是如何实现这个小小的进度条的,但是。。。据我所知,您需要为此创建自定义视图,对吗?如下所示:创建一个新类,如RefreshMenuItemHel

在扩展ActionBarActivity的活动中,我使用
supportRequestWindowFeature(Window.FEATURE\u Undeterminate\u PROGRESS)和<代码>设置支持进程BarInDeterminateVibility(真)
将小进度对话框显示为actionbar项目菜单

如何将更多内容分离到屏幕上

谢谢


我不知道你是如何实现这个小小的进度条的,但是。。。据我所知,您需要为此创建自定义视图,对吗?如下所示:创建一个新类,如RefreshMenuItemHelper:

public class RefreshMenuItemHelper {
    private WeakReference<MenuItem> item;

    /**
     * Set the menu item.
     * @param item
     */
    public void setMenuItem(MenuItem item) {
        this.item = new WeakReference<MenuItem>(item);
    }

    /**
     * Show the indeterminate progress.
     */
    public void showLoading() {
        if(item != null) {
            item.get().setActionView(R.layout.menu_item_action_refresh);
            item.get().expandActionView();
        }
    }

    /**
     * Stop and dismiss the indeterminate progress.
     */
    public void stopLoading() {
        item.get().collapseActionView();
        item.get().setActionView(null);
    }

}
现在可以使用showLoading()和stopLoading()来启动或停止不确定的进程。还要确保menu.xml在R.id.action\u refresh中包含ic_refresh.png


希望对你有帮助

谢谢@nicolas jafelle!我将尝试此解决方案并对结果进行评论。微进度对话框是android提供的一个菜单,带有supportRequestWindowFeature(Window.FEATURE\u Undeterminate\u进度);和设置支持进程BarindeTerminateVibility(true);请添加一些与refreshHelper变量相关的代码。我想使用空指针。谢谢我创建了类并设置了菜单项,但showLoading()的使用并不取决于用户是否在oncreate()中单击菜单项创建RefreshMenuItemHelper的新实例,如:RefreshMenuItemHelper=new RefreshMenuItemHelper();
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="56dp"
    android:layout_height="wrap_content"
    android:minWidth="56dp">
    <ProgressBar
        android:layout_width="32dp"
        android:layout_height="32dp"
        android:layout_gravity="center"/>
</FrameLayout>
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.action_refresh:
                refreshHelper.setMenuItem(item);
            default:
                return super.onOptionsItemSelected(item);
        }
    }