OSDN Git Service

Improve the appearance of the minitabs on the landing page.
authorLeon Scroggins <scroggo@google.com>
Fri, 28 Aug 2009 15:44:12 +0000 (11:44 -0400)
committerLeon Scroggins <scroggo@google.com>
Fri, 28 Aug 2009 17:13:14 +0000 (13:13 -0400)
Use the default look, but modified to be shorter in height.

Change-Id: Ib0b8a6ab4ce0a809504d92a2b40ac39224264626

src/com/android/browser/CombinedBookmarkHistoryActivity.java

index efe6292..bed926e 100644 (file)
@@ -36,6 +36,7 @@ import android.webkit.WebIconDatabase.IconListener;
 import android.widget.LinearLayout;
 import android.widget.TabHost;
 import android.widget.TabHost.TabSpec;
+import android.widget.TabWidget;
 import android.widget.TextView;
 
 import java.util.HashMap;
@@ -163,7 +164,6 @@ public class CombinedBookmarkHistoryActivity extends TabActivity
         getTabHost().setOnTabChangedListener(this);
 
         Bundle extras = getIntent().getExtras();
-        Resources resources = getResources();
 
         getIconListenerSet(getContentResolver());
 
@@ -187,15 +187,28 @@ public class CombinedBookmarkHistoryActivity extends TabActivity
         if (defaultTab != null) {
             getTabHost().setCurrentTab(2);
         }
+        // For each of our tabs, reduce its height by setting the icon
+        // view to gone, and setting a height.
+        TabWidget widget = getTabWidget();
+        int count = widget.getTabCount();
+        for (int i = 0; i < count; i++) {
+            View header = widget.getChildTabViewAt(i);
+            if (null == header) break;
+            View icon = header.findViewById(android.R.id.icon);
+            if (null == icon) break;
+            icon.setVisibility(View.GONE);
+            LinearLayout.LayoutParams lp
+                = (LinearLayout.LayoutParams) header.getLayoutParams();
+            lp.height = 30;
+        }
+        widget.requestLayout();
     }
 
     private void createTab(Intent intent, int labelResId, String tab) {
-        LayoutInflater factory = LayoutInflater.from(this);
-        View tabHeader = factory.inflate(R.layout.tab_header, null);
-        TextView textView = (TextView) tabHeader.findViewById(R.id.tab_label);
-        textView.setText(labelResId);
+        Resources resources = getResources();
         TabHost tabHost = getTabHost();
-        tabHost.addTab(tabHost.newTabSpec(tab).setIndicator(tabHeader).setContent(intent));
+        tabHost.addTab(tabHost.newTabSpec(tab).setIndicator(
+                resources.getText(labelResId)).setContent(intent));
     }
     // Copied from DialTacts Activity
     /** {@inheritDoc} */