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" />
这样就和旁边的一样来了。
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" />
这样就和旁边的一样来了。
相关文章推荐
- 如何处理小图标与文字混排的多种解决方案
- android Launcher hotseat上图标拖动事件触动的时间
- (个人原创)zabbix 图标下方文字显示为方块的处理办法
- android 让Launcher Hotseat中的图标显示title
- win7系统没有桌面图标只有文字该怎么处理?
- Launcher hotseat上icon显示文字的修改
- 图标和文字无法对齐处理方法
- Android Launcher 应用图标大小不一的情况或GirdView Item 不规则处理与解决
- Android 4.0 修改Launcher 应用图标文字大小
- launcher3图标icon背景及文字处理
- 桌面图标的文字背景色如何恢复为透明
- Google购文字处理软件Writely 拟推在线Office
- Fireworks 绘制立体文字图标
- 转一个,桌面图标下文字去底色的方法
- 终极Struts中文及其它语言文字处理问题(文字国际化)
- MIDP中处理文字的换行
- asp.net下GDI+的一些常用应用(水印,文字,圆角处理)技巧
- [转]文字还是图标?
- perl语言文字处理模式
- vi 文字处理软件