-3

Hello Guys 如何在图标下排列 appname ?如果你需要我给出来源。

在此处输入图像描述

您可以在此处查看用于创建此视图的代码:

package com.example.draw;

import java.util.List;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class AppInfoAdapter extends BaseAdapter {
    private Context mContext;
    private List<ApplicationInfo> mListAppInfo;
    private PackageManager mPackManager;

    public AppInfoAdapter(Context c, List<ApplicationInfo> list, PackageManager pm) {
        mContext = c;
        mListAppInfo = list;
        mPackManager = pm;
    }

    @Override
    public int getCount() {
        return mListAppInfo.size();
    }

    @Override
    public Object getItem(int position) {
        return mListAppInfo.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // get the selected entry
        ApplicationInfo entry = mListAppInfo.get(position);

        // reference to convertView
        View v = convertView;

        // inflate new layout if null
        if(v == null) {
            LayoutInflater inflater = LayoutInflater.from(mContext);
            v = inflater.inflate(R.layout.activity_appinfo, null);
        }

        // load controls from layout resources
        ImageView ivAppIcon = (ImageView)v.findViewById(R.id.ivIcon);



        // set data to display
        ivAppIcon.setImageDrawable(entry.loadIcon(mPackManager));



        // return view
        return v;
    }
}

文本来自 TextView tvAppName = (TextView)v.findViewById(R.id.tvName); tvAppName.setText(entry.loadLabel(mPackManager));

main_appinfo.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="?android:attr/listPreferredItemHeight"
    android:orientation="horizontal"
    android:padding="5dip" >

  <ImageView
      android:id="@+id/ivIcon"
      android:layout_width="wrap_content"
      android:layout_height="fill_parent"
      android:layout_gravity="center"
      android:layout_weight="1"
      android:contentDescription="@string/desc"
      android:scaleType="center" 
      android:gravity="center_horizontal|center_vertical"/>

</LinearLayout>
4

2 回答 2

0

布局文件中的LinearLayout水平,使其垂直。

android:orientation="horizontal"android:orientation="vertical"

于 2013-02-06T16:02:37.377 回答
-1

应用图标和标题格式是android主屏幕应用的一部分,您无法修改其外观。

如果您愿意,您可以创建自己的主屏幕应用程序并使用它做任何您想做的事情。

这是主屏幕应用程序的示例:Home App Android sdk Sample

于 2013-02-06T15:02:12.100 回答