【问题标题】:Standalone ToolBar, how to fill all space with links独立工具栏,如何用链接填充所有空间
【发布时间】:2015-08-26 16:41:22
【问题描述】:

在我的应用程序中,我在顶部有一个作为 ActionBar 的 ToolBar,在底部有一个独立的 ToolBar。底部工具栏在右侧显示两个链接和操作菜单,但在左侧留下了很大的空间,大概是应用程序图像和标题。我想将这个空间用于更多链接。我一直无法找到一种方法来做到这一点。我找到了这些填充选项,但它们没有影响任何更改...

    android:contentInsetStart="0dp"
    android:contentInsetLeft="0dp"
    app:contentInsetLeft="0dp"
    app:contentInsetStart="0dp"

这是工具栏的 xml

    android:id="@+id/toolbarbottom"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@android:color/darker_gray"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" >

</android.support.v7.widget.Toolbar>

这里是java代码...

    Toolbar toolbarBottom = (Toolbar) findViewById(R.id.toolbarbottom);
    toolbarBottom.inflateMenu(R.menu.mainbottom);
    toolbarBottom.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
                case R.id.webview:               // Web View
                    BrowseWWW();
                    return true;

                case R.id.jsoupview:             // Jsoup View
                    LoadHTMLJsoup();
                    return true;

                case R.id.codeview:               // Code View
                    LoadHTMLCode();
                    return true;

                case R.id.connview:              // Connectivity View
                    GetHTMLConn();
                    return true;

                case R.id.ftpview:               // Ftp View
                    GetHTMLFtp();
                    return true;
            }
            return true;
        }
    });

还有菜单...

<item android:id="@+id/webview"
    android:title="@string/webview"
    HTMLSpyII:showAsAction="always|withText" />

<item android:id="@+id/jsoupview"
    android:title="@string/jsoupview"
    HTMLSpyII:showAsAction="always|withText" />

<item android:id="@+id/codeview"
    android:title="@string/codeview"
    HTMLSpyII:showAsAction="ifRoom|withText" />

<item android:id="@+id/connview"
    android:title="@string/Connectivity"
    HTMLSpyII:showAsAction="ifRoom|withText" />

<item android:id="@+id/ftpview"
    android:title="@string/ftpview"
    HTMLSpyII:showAsAction="ifRoom|withText" />

【问题讨论】:

    标签: android toolbar


    【解决方案1】:

    您应该能够扩展自己的布局并将其设置在工具栏上。像这样的:

    LayoutInflater inflater = LayoutInflater.from(context);
    View view = inflater.inflate(R.layout.custom_layout, null);
    mToolbar.addView(view);
    

    【讨论】:

    猜你喜欢
    • 2010-09-18
    • 1970-01-01
    • 1970-01-01
    • 2018-12-18
    • 2012-10-26
    • 2020-01-14
    • 2019-09-27
    • 2012-05-11
    • 2010-11-13
    相关资源
    最近更新 更多