Browser首页为一张图片
根据D:\adt-bundle-windows-x86-20130522\sdk\tools\hierarchyviewer.bat 我找到了相关布局文件和一个Java文件。远程修改如下:
以下是添加的图片,系统会根据分辨率到不同目录下调用图片,所以在不同分辨率下都要放一张。
rico@rico-PC:~/workspace/program/a23/android4.4/packages/apps/Browser$ git status
On branch ak707-kitkat-v2.0
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: res/layout/tab.xml
modified: src/com/android/browser/BaseUi.java
Untracked files:
(use "git add <file>..." to include in what will be committed)
res/drawable-hdpi/bootlogo.png
res/drawable-mdpi/bootlogo.png
res/drawable-sw600dp-hdpi/bootlogo.png
res/drawable-sw600dp-mdpi/bootlogo.png
res/drawable-sw600dp-xhdpi/bootlogo.png
res/drawable-xhdpi/bootlogo.png
no changes added to commit (use "git add" and/or "git commit -a")
以下是布局文件,主要是添加了一个logo图片居中显示:
rico@rico-PC:~/workspace/program/a23/android4.4/packages/apps/Browser$ git diff res/layout/tab.xml
diff --git a/res/layout/tab.xml b/res/layout/tab.xml
index 69baf56..517303e 100755
--- a/res/layout/tab.xml
+++ b/res/layout/tab.xml
@@ -19,17 +19,30 @@
Currently, the only such element is the Geolocation permissions prompt.
-->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="match_parent" >
<!-- Wrapper layout for the WebView, which must be in a FrameLayout. -->
<FrameLayout android:id="@+id/webview_wrapper"
android:layout_width="match_parent"
- android:layout_height="0dip"
- android:layout_weight="1" />
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:background="#0000ff" />
+
+ <ImageView
+ android:id="@+id/ivLogo"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:scaleX="1.5"
+ android:scaleY="1.5"
+ android:background="@drawable/bootlogo"
+ android:text="@string/dump_nav"
+ android:textSize="40sp"
+ android:layout_centerInParent="true" />
+
<!-- Geolocation permissions prompt -->
<ViewStub android:id="@+id/geolocation_permissions_prompt"
@@ -37,4 +50,4 @@
android:layout_width="match_parent"
android:layout_height="wrap_content" />
-</LinearLayout>
+</RelativeLayout>
以下是Java文件,主要是点击logo图片便使其消失:
rico@rico-PC:~/workspace/program/a23/android4.4/packages/apps/Browser$ git diff src/com/android/browser/BaseUi.java
diff --git a/src/com/android/browser/BaseUi.java b/src/com/android/browser/BaseUi.java
index 6b10459..143e608 100644
--- a/src/com/android/browser/BaseUi.java
+++ b/src/com/android/browser/BaseUi.java
@@ -53,7 +53,8 @@ import android.widget.Toast;
import com.android.browser.Tab.SecurityState;
import com.android.internal.view.menu.MenuBuilder;
-
+import android.widget.ImageView;
+import android.view.View.OnClickListener;
import java.util.List;
/**
@@ -375,6 +376,7 @@ public abstract class BaseUi implements UI {
// needed by WebView.
FrameLayout wrapper =
(FrameLayout) container.findViewById(R.id.webview_wrapper);
+// ImageView ivLogo = (ImageView) container.findviewById(R.id.ivLogo);
wrapper.removeView(mainView);
mContentView.removeView(container);
mUiController.endActionMode();
@@ -385,6 +387,7 @@ public abstract class BaseUi implements UI {
}
}
+ ImageView ivLogo;
@Override
public void onSetWebView(Tab tab, WebView webView) {
View container = tab.getViewContainer();
@@ -393,6 +396,18 @@ public abstract class BaseUi implements UI {
// WebView, as well as any other UI elements associated with the tab.
container = mActivity.getLayoutInflater().inflate(R.layout.tab,
mContentView, false);
+ ivLogo = (ImageView) container.findViewById(R.id.ivLogo);
+
+ ivLogo.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ ivLogo.setVisibility(View.GONE);
+ }
+ });
+
tab.setViewContainer(container);
}
if (tab.getWebView() != webView) {