搜索查看关于support.v7.appcompat库问题:默认的9补丁背景不能正确显示, [英] SearchView on support.v7.appcompat library issue: default 9-patch background not renders properly

查看:132
本文介绍了搜索查看关于support.v7.appcompat库问题:默认的9补丁背景不能正确显示,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发使用support.v7.appcompat库动作条的应用程序。操作栏的作品中,搜索查看显示,提示节目。唯一的问题是,和SearchView的背景未被scalling正常。平时的欧洲工商管理学院,看来大,与9补丁的黑线。

I'm developing an app with ActionBar using support.v7.appcompat library. The action bar works, the SearchView is shown, the hint shows. The only problem is that the background of the SearchView is not scalling properly. Insead of the usual, it appears big and with the 9-patch black lines.

  • 从命令行开发,使用蚂蚁调试编译。
  • 在Linux的Mageia 3,蚂蚁版本:Apache Ant的(TM)1.8.4版本编译于2013年1月11日
  • 链接到库project.properties行:
  • Developing from command line, using ant debug to compile.
  • On Linux Mageia 3, ant version: Apache Ant(TM) version 1.8.4 compiled on January 11 2013
  • Linking to library with project.properties line:

android.library.reference.1 = .. / .. / .. / .. / .. / SDK /演员/安卓/支持/ V7 / appcompat /

android.library.reference.1=../../../../../sdk/extras/android/support/v7/appcompat/

  • 使用@风格/ Theme.AppCompat.Light
  • 在经过​​测试,在设备与CM10-1,在设备与库存4.1和仿真器API 8(Android 2.2的)。相同的结果的所有设备。

import android.support.v7.app.ActionBarActivity;
import android.support.v7.widget.SearchView;
import android.support.v4.view.MenuItemCompat;
import android.app.Activity;
import android.app.SearchManager;
import android.content.Context;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MenuInflater;


public class DiccionariCatala extends ActionBarActivity
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {   
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }   

    @Override
    public boolean onCreateOptionsMenu(Menu menu){
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.menu_actions, menu);
        SearchManager SManager =  (SearchManager) getSystemService(Context.SEARCH_SERVICE);
        MenuItem searchMenuItem = menu.findItem(R.id.action_search);
        SearchView searchViewAction = (SearchView) MenuItemCompat.getActionView(searchMenuItem);
        searchViewAction.setSearchableInfo(SManager.getSearchableInfo(getComponentName()));
        searchViewAction.setIconifiedByDefault(false);
        return super.onCreateOptionsMenu(menu);
    }   

    @Override
    public boolean onOptionsItemSelected(MenuItem item){
        switch (item.getItemId()) {
                case R.id.action_search:
                    //openSearch();
                    return true;
                default:
                    return super.onOptionsItemSelected(item);
        }   
    }      
}

menu_actions.xml(菜单的xml)

<menu xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:diccionaricatala="http://schemas.android.com/apk/res-auto" >
    <item android:id="@+id/action_search"
          android:title="@string/action_search_title"
          diccionaricatala:showAsAction="ifRoom"
          diccionaricatala:actionViewClass="android.support.v7.widget.SearchView" />
</menu>

的Andr​​oidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.mypackage.apps"
      android:versionCode="1"
      android:versionName="1.0">
      <uses-sdk android:minSdkVersion="8"  android:targetSdkVersion="16"/>
      <application android:label="@string/app_name"
                   android:icon="@drawable/ic_launcher"
                   android:theme="@style/Theme.AppCompat.Light">

       <activity android:name="DiccionariCatala"
                 android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.SEARCH" />
            </intent-filter>
            <meta-data android:name="android.app.searchable"
                       android:resource="@xml/searchable"/>
        </activity>
   </application>
</manifest>

project.properties

target=android-16
android.library.reference.1=../../../../../sdk/extras/android/support/v7/appcompat/

任何帮助了我太大的preciated。我找不到任何错误,而且也奇怪事实despide这一点,其他一切工作。谢谢你。

Any help would me much apreciated. I can't find anything wrong, and there's also the weird fact that despide this, everything else work. Thanks.

推荐答案

好吧,我想自杀。我已经解决了。不知道怎么办。我不能再重现错误!

Ok, I want to kill myself. I've fixed it. Don't know how. I can't reproduce the bug again!

我觉得有固定的错误:我添加了进口android.support.v7.app.ActionBar;

what I think has fixed the bug: I've added import android.support.v7.app.ActionBar;

然后我删除它重现错误,但它不是回来了。

Then I've removed it to reproduce the bug, but it's not back.

我也没有卸载内置工具18.0.1(这是斜体字,使我怀疑),所以我想这可能是错误的来源。但我已经重新安装了,并且无法重现错误或者。

I also did uninstall Build-tools 18.0.1 (which is in italics and made me suspicious), so I thought it might be the source of the bug. But I've reinstalled it, and can't reproduce the bug either.

我不知道还有什么可能可能是。无论如何,移动上...(景象)

I don't know what else could possibly be. Anyway, moving on... (sight)

它再次发生,这一次我已经能够缩小下来。原来它是生成工具V18的错误。*,降级到V17解决了这个问题。

这篇关于搜索查看关于support.v7.appcompat库问题:默认的9补丁背景不能正确显示,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆