删除选项卡活动上的深色覆盖层(android)

发布于 2024-11-09 17:18:02 字数 5802 浏览 0 评论 0原文

我使用此方法制作了自定义选项卡: http://bakhtiyor.com/2009/10/ iphonish-tabs/

似乎当选择每个选项卡时都会出现轻微的黑色覆盖,请参见此屏幕截图:

tab image

我希望颜色与选项卡底部和屏幕的其余部分无缝衔接。谁能告诉我如何摆脱覆盖/黑暗?

谢谢:)

这是选项卡布局 xml:

    <TabHost xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@android:id/tabhost"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
  <RelativeLayout android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <FrameLayout android:id="@android:id/tabcontent"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:layout_weight="1"
      android:padding="5dip"
      android:background="#ede7da"
      android:layout_marginTop="50dip"/>
    <RadioGroup android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:orientation="horizontal"
      android:checkedButton="@+id/first"
      android:id="@+id/states">
      <RadioButton android:id="@+id/first"
      android:background="@drawable/button_radio"
      android:text="Settings"
      android:textColor="#dda88f"
      android:textSize="12dip"
      android:gravity="center"
        android:width="80dip"
        android:height="70dip" />
      <RadioButton android:id="@+id/second"
      android:background="@drawable/button_radio"
      android:text="Reminders"
      android:textColor="#dda88f"
      android:textSize="12dip"
      android:gravity="center"
        android:width="80dip"
        android:height="70dip" />
      <RadioButton android:id="@+id/third"
      android:background="@drawable/button_radio"
      android:text="Help"
      android:textColor="#dda88f"
      android:textSize="12dip"
      android:gravity="center"
        android:width="80dip"
        android:height="70dip" />
        <RadioButton android:id="@+id/fourth"
      android:background="@drawable/button_radio"
      android:text="Spare"
      android:textColor="#dda88f"
      android:textSize="12dip"
      android:gravity="center"
        android:width="80dip"
        android:height="70dip" />
    </RadioGroup>
    <com.bitty.kegelkat.PopupButton
                android:id="@+id/okbutton"
                android:background="@drawable/popup_button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_centerHorizontal="true"
                android:layout_marginBottom="16dp"
                android:textColor="#b6b6b6"
                android:textSize="30sp"
                android:text="OK"
                />
    <TabWidget android:id="@android:id/tabs"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_weight="0"
      android:visibility="gone" />
  </RelativeLayout>
</TabHost>

这是选项卡代码:

setupUI();

        Resources res = getResources(); // Resource object to get Drawables
        TabHost tabHost = getTabHost();  // The activity TabHost
        TabHost.TabSpec spec;  // Resusable TabSpec for each tab
        Intent intent;  // Reusable Intent for each tab

        // Create an Intent to launch an Activity for the tab (to be reused)
        intent = new Intent().setClass(this, Settings.class);

        // Initialize a TabSpec for each tab and add it to the TabHost
        spec = tabHost.newTabSpec("settings").setIndicator("Settings",
                          res.getDrawable(R.drawable.tab_settings))
                      .setContent(intent);
        tabHost.addTab(spec);

        // Do the same for the other tabs
        intent = new Intent().setClass(this, Reminders.class);
        spec = tabHost.newTabSpec("reminders").setIndicator("Reminders",
                          res.getDrawable(R.drawable.tab_settings))
                      .setContent(intent);
        tabHost.addTab(spec);

        intent = new Intent().setClass(this, About.class);
        spec = tabHost.newTabSpec("about").setIndicator("Help/About",
                          res.getDrawable(R.drawable.tab_settings))
                      .setContent(intent);
        tabHost.addTab(spec);

        tabHost.setCurrentTab(0);

private void setupUI() {
        RadioButton rbFirst = (RadioButton) findViewById(R.id.first);
        RadioButton rbSecond = (RadioButton) findViewById(R.id.second);
        RadioButton rbThird = (RadioButton) findViewById(R.id.third);
        RadioButton rbFourth = (RadioButton) findViewById(R.id.fourth);
        rbFirst.setButtonDrawable(R.drawable.blank);
        rbSecond.setButtonDrawable(R.drawable.blank);
        rbThird.setButtonDrawable(R.drawable.blank);
        rbFourth.setButtonDrawable(R.drawable.blank);
        RadioGroup rg = (RadioGroup) findViewById(R.id.states);
        rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            public void onCheckedChanged(RadioGroup group, final int checkedId) {
                switch (checkedId) {
                case R.id.first:
                    getTabHost().setCurrentTab(0);
                    break;
                case R.id.second:
                    getTabHost().setCurrentTab(1);
                    break;
                case R.id.third:
                    getTabHost().setCurrentTab(2);
                    break;
                case R.id.fourth:
                    getTabHost().setCurrentTab(3);
                    break;
                }
            }
        });

i have made custom tabs using this method: http://bakhtiyor.com/2009/10/iphonish-tabs/

it seems as though when each tab is selected there is a slight dark overlay occurring, see this screenshot:

tab image

i'd like the color to be seamless with the bottom of the tabs and the rest of the screen. can anyone tell me how to get rid of the overlay/darkness?

thanks :)

here's the tab layout xml:

    <TabHost xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@android:id/tabhost"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
  <RelativeLayout android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <FrameLayout android:id="@android:id/tabcontent"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:layout_weight="1"
      android:padding="5dip"
      android:background="#ede7da"
      android:layout_marginTop="50dip"/>
    <RadioGroup android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:orientation="horizontal"
      android:checkedButton="@+id/first"
      android:id="@+id/states">
      <RadioButton android:id="@+id/first"
      android:background="@drawable/button_radio"
      android:text="Settings"
      android:textColor="#dda88f"
      android:textSize="12dip"
      android:gravity="center"
        android:width="80dip"
        android:height="70dip" />
      <RadioButton android:id="@+id/second"
      android:background="@drawable/button_radio"
      android:text="Reminders"
      android:textColor="#dda88f"
      android:textSize="12dip"
      android:gravity="center"
        android:width="80dip"
        android:height="70dip" />
      <RadioButton android:id="@+id/third"
      android:background="@drawable/button_radio"
      android:text="Help"
      android:textColor="#dda88f"
      android:textSize="12dip"
      android:gravity="center"
        android:width="80dip"
        android:height="70dip" />
        <RadioButton android:id="@+id/fourth"
      android:background="@drawable/button_radio"
      android:text="Spare"
      android:textColor="#dda88f"
      android:textSize="12dip"
      android:gravity="center"
        android:width="80dip"
        android:height="70dip" />
    </RadioGroup>
    <com.bitty.kegelkat.PopupButton
                android:id="@+id/okbutton"
                android:background="@drawable/popup_button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_centerHorizontal="true"
                android:layout_marginBottom="16dp"
                android:textColor="#b6b6b6"
                android:textSize="30sp"
                android:text="OK"
                />
    <TabWidget android:id="@android:id/tabs"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_weight="0"
      android:visibility="gone" />
  </RelativeLayout>
</TabHost>

and here's the tab code:

setupUI();

        Resources res = getResources(); // Resource object to get Drawables
        TabHost tabHost = getTabHost();  // The activity TabHost
        TabHost.TabSpec spec;  // Resusable TabSpec for each tab
        Intent intent;  // Reusable Intent for each tab

        // Create an Intent to launch an Activity for the tab (to be reused)
        intent = new Intent().setClass(this, Settings.class);

        // Initialize a TabSpec for each tab and add it to the TabHost
        spec = tabHost.newTabSpec("settings").setIndicator("Settings",
                          res.getDrawable(R.drawable.tab_settings))
                      .setContent(intent);
        tabHost.addTab(spec);

        // Do the same for the other tabs
        intent = new Intent().setClass(this, Reminders.class);
        spec = tabHost.newTabSpec("reminders").setIndicator("Reminders",
                          res.getDrawable(R.drawable.tab_settings))
                      .setContent(intent);
        tabHost.addTab(spec);

        intent = new Intent().setClass(this, About.class);
        spec = tabHost.newTabSpec("about").setIndicator("Help/About",
                          res.getDrawable(R.drawable.tab_settings))
                      .setContent(intent);
        tabHost.addTab(spec);

        tabHost.setCurrentTab(0);

private void setupUI() {
        RadioButton rbFirst = (RadioButton) findViewById(R.id.first);
        RadioButton rbSecond = (RadioButton) findViewById(R.id.second);
        RadioButton rbThird = (RadioButton) findViewById(R.id.third);
        RadioButton rbFourth = (RadioButton) findViewById(R.id.fourth);
        rbFirst.setButtonDrawable(R.drawable.blank);
        rbSecond.setButtonDrawable(R.drawable.blank);
        rbThird.setButtonDrawable(R.drawable.blank);
        rbFourth.setButtonDrawable(R.drawable.blank);
        RadioGroup rg = (RadioGroup) findViewById(R.id.states);
        rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            public void onCheckedChanged(RadioGroup group, final int checkedId) {
                switch (checkedId) {
                case R.id.first:
                    getTabHost().setCurrentTab(0);
                    break;
                case R.id.second:
                    getTabHost().setCurrentTab(1);
                    break;
                case R.id.third:
                    getTabHost().setCurrentTab(2);
                    break;
                case R.id.fourth:
                    getTabHost().setCurrentTab(3);
                    break;
                }
            }
        });

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文