获取应用程序图标的安卓应用程序、图标

由网友(你心移动,我心怎能联通)分享简介:我有一些麻烦检索图标安装Android应用程序。有的用大图标的同时 - 以下code返回图标所有的应用程序,但是,一些应用程序都以小图标(LDPI文件夹可能是从绘制)返回。 I'm having some trouble retrieving icons for installed Android App. The...

我有一些麻烦检索图标安装Android应用程序。有的用大图标的同时 - 以下code返回图标所有的应用程序,但是,一些应用程序都以小图标(LDPI文件夹可能是从绘制)返回。

I'm having some trouble retrieving icons for installed Android App. The following code returns icons for all apps, however, some apps are returned with small icons (perhaps from drawable - ldpi folder) while some with large icons.

List<PackageInfo> package = getPackageManager().getInstalledPackages(0);

for(PackageInfo p : package){
    iApp.icon = p.applicationInfo.loadIcon(getPackageManager()); 
}

我怎样才能得到它的图标都是一样的大小,就像在管理的Andr​​oid应用程序部分?

How Can I get icons which are all of the same size, just like in Manage Application section of Android?

推荐答案

应用程序可能只是有不同大小的图标。 Android的设置应用程序加载图标只是喜欢你。显示它们在缩放时的图标。

Apps might just have different sized icons. The Android Settings app loads icons just like you. It scales the icons when displaying them.

下面是从一个片段封装/应用程序/设置/ RES /布局/ manage_applications_item.xml:

Here's a snippet from packages/apps/Settings/res/layout/manage_applications_item.xml:

<ImageView android:id="@+id/app_icon"
    android:layout_width="@android:dimen/app_icon_size"
    android:layout_height="@android:dimen/app_icon_size"
    android:layout_marginRight="11dip"
    android:layout_gravity="center_vertical"
    android:scaleType="fitCenter"/>
阅读全文

相关推荐

最新文章