小编Gre*_*ann的帖子

使用SearchView android studio在工具栏中留下空间

我正在尝试SearchView在我的应用中添加一个简单的工具栏.它所做的一切都很好用于布局.

NavigationDrawer图标和图标之间有这个"空间" SearchView.如果我设置标题,则该空格将填充该字符串,否则为空.

空字符串:

在此输入图像描述

标题中包含一个字符串:

在此输入图像描述

如何删除烦人的空白区域?

编辑:

我正在使用NavigationDrawerAndroid Studio中的示例作为基本代码

main.xml中

    <menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context=".MainActivity"
    >

    <item
        android:id="@+id/action_search"
        android:icon="@android:drawable/ic_menu_search"
        android:title="Search"
        app:actionViewClass="android.support.v7.widget.SearchView"
        app:showAsAction="always" />

    </menu>
Run Code Online (Sandbox Code Playgroud)

app_bar_main.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="ga.musicforyou.musicforyou.MainActivity">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
       >

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            app:contentInsetEnd="0dp"
            app:contentInsetStart="0dp"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            />

    </android.support.design.widget.AppBarLayout>


</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

activity_main.xml中

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">

    <include
        layout="@layout/app_bar_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        app:theme="@style/ThemeOverlay.AppCompat.Dark"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start" …
Run Code Online (Sandbox Code Playgroud)

java android searchview android-toolbar

11
推荐指数
1
解决办法
2664
查看次数

xmlhttprequest同时请求不起作用

我正在尝试制作"许多" xhr请求,但似乎每次在提出另一个请求之前等待答案.这就像XHR组成队列并始终等待前一个请求完成.

如何同时运行更多xhr请求?

$('body').delegate('.download','click', function(evt){
        evt.preventDefault(); // Not related

        var xhr = new XMLHttpRequest();
        xhr.open('GET', "proxy.php?" + this.href, true);
        xhr.responseType = 'blob';

        xhr.onload = function() {
            if (this.status == 200) {              
                var blob = new Blob([this.response], {type:'audio/mp4'});

                console.log(blob.size);
                if(blob.size > 0){
                    $("<a>").attr({
                        download: name,
                        href: URL.createObjectURL(blob),
                        target: "_blank"
                    })[0].click();
                }
            }
        };  
        xhr.send();
    });
Run Code Online (Sandbox Code Playgroud)

javascript asynchronous xmlhttprequest

10
推荐指数
1
解决办法
421
查看次数

将 SVG 缩放到固定高度

我有许多国家/地区的国旗被保存为具有固定高度和宽度的 SVG,每个国旗之间都不同(有些是 1000x700 其他是 1500x300 等)

例子:

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1000" height="700"></svg>
Run Code Online (Sandbox Code Playgroud)

https://codepen.io/anon/pen/aypvdj

我想要做的是将其缩放到更小的尺寸。

我不明白如何使用固定高度(例如 80px)和宽度自动缩放进行缩放。

html css svg

0
推荐指数
1
解决办法
1192
查看次数