您的位置:首页 > 其它

launcher3的hotseat的图标文字处理

2015-01-19 16:23 363 查看
隐藏文件夹图标的 标题文字

packages\apps\Launcher3\src\com\android\launcher3\Workspace.java

void addInScreen(View child, long container, long screenId, int x, int y, int spanX, int spanY,

boolean insert, boolean computeXYFromRank) {

...

// Hide folder title in the hotseat

if (child instanceof FolderIcon) {

((FolderIcon) child).setTextVisible(false);

}

if (computeXYFromRank) {

x = mLauncher.getHotseat().getCellXFromOrder((int) screenId);

y = mLauncher.getHotseat().getCellYFromOrder((int) screenId);

} else {

screenId = mLauncher.getHotseat().getOrderInHotseat(x, y);

}

} else {

// Show folder title if not in the hotseat

if (child instanceof FolderIcon) {

//((FolderIcon) child).setTextVisible(true);

((FolderIcon) child).setTextVisible(false); //modefied by xun

}

...

}

添加快捷键图标的 标题文字

packages\apps\Launcher3\src\com\android\launcher3\CellLayout.java

public boolean addViewToCellLayout(View child, int index, int childId, LayoutParams params,

boolean markCells) {

...

// Hotseat icons - remove text

if (child instanceof BubbleTextView) {

BubbleTextView bubbleChild = (BubbleTextView) child;

// bubbleChild.setTextVisibility(!mIsHotseat);

bubbleChild.setTextVisibility(true); //true为显示

}

...

}

如果还是没有显示那是因为hotseat高度太小了.packages\apps\Launcher3\src\com\android\launcher3\DynamicGrid.java

// Hotseat

hotseatBarHeightPx = iconSizePx + 25 * edgeMarginPx;//设置高度

添加allAppsbutton 文字

packages\apps\Launcher3\src\com\android\launcher3\Hotseat.java

void resetLayout() {

LayoutInflater inflater = LayoutInflater.from(context);

TextView allAppsButton = (TextView)

inflater.inflate(R.layout.all_apps_button, mContent, false);

Drawable d = context.getResources().getDrawable(R.drawable.all_apps_button_icon);

Utilities.resizeIconDrawable(d);

allAppsButton.setCompoundDrawables(null, d, null, null);

allAppsButton.setContentDescription(context.getString(R.string.all_apps_button_label));

allAppsButton.setText(context.getString(R.string.all_apps_button_label)); //添加文字

}

all_apps_button.xml 文件修改

<item name="android:textSize">28dp</item>

<item name="android:shadowDx">0</item>

<item name="android:shadowDy">3</item>

<item name="android:shadowRadius">4.0</item>

<item name="android:shadowColor">#ee000000</item>

以上这样,虽然能把文字显示出来,但是发现文字的大小和位置都和其他的图标不一样,整体看起来很别扭。所以还要修改下

由于launcher桌面的图标文字是有类 BubbleTextView 完成的,所以在这里让 allAppsButton 继承 BubbleTextView 而不是原先的TextView 。

如下:

void resetLayout() {

mContent.removeAllViewsInLayout();

if (!AppsCustomizePagedView.DISABLE_ALL_APPS) {

// Add the Apps button

Context context = getContext();

LayoutInflater inflater = LayoutInflater.from(context);

BubbleTextView allAppsButton = (BubbleTextView)

inflater.inflate(R.layout.all_apps_button, mContent, false);

Drawable d = context.getResources().getDrawable(R.drawable.all_apps_button_icon);

Utilities.resizeIconDrawable(d);

allAppsButton.setCompoundDrawables(null, d, null, null);

LauncherAppState app = LauncherAppState.getInstance();

DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();

allAppsButton.setCompoundDrawablePadding((int) ((grid.folderIconSizePx - grid.iconSizePx) / 2f));

allAppsButton.setText(context.getString(R.string.all_apps_button_label)); //

allAppsButton.setContentDescription(context.getString(R.string.all_apps_button_label));

...

}

packages\apps\Launcher3\res\layout\all_apps_button.xml

<com.android.launcher3.BubbleTextView

xmlns:android="http://schemas.android.com/apk/res/android"

style="@style/WorkspaceIcon"

android:focusable="true"

android:background="@drawable/focusable_view_bg" />

这样就和旁边的一样来了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: