tabpageIndicator的背景是黑色的,怎么去掉?

android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
android:id="@+id/tpi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<com.viewpagerindicator.TabPageIndicator
android:id="@+id/tpi2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

        />
</RelativeLayout>


<android.support.v4.view.ViewPager
    android:id="@+id/vp"
    android:layout_width="match_parent"
     android:layout_height="match_parent"
    ></android.support.v4.view.ViewPager>

 package com.itheima.tab;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.viewpagerindicator.TabPageIndicator;

public class HomeActivity extends Activity {

    private TabPageIndicator tpi;
    private TabPageIndicator tpi2;
    private ViewPager vp;

    private String[] title={"中国","北京","上海","深圳","广州","国际"};
    private int images[]={R.drawable.after1,R.drawable.after2,R.drawable.after3,R.drawable.after4,R.drawable.after5,R.drawable.after6};
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tpi = (TabPageIndicator) findViewById(R.id.tpi);
        tpi2 = (TabPageIndicator) findViewById(R.id.tpi2);
        vp = (ViewPager) findViewById(R.id.vp);
        initView();
    }
    private void initView() {
        vp.setAdapter(new ViewPagerAdapter());
        tpi.setViewPager(vp);
    } 
    class ViewPagerAdapter extends PagerAdapter{

        @Override
        public int getCount() {
            // TODO Auto-generated method stub
            return title.length;
        }

        @Override
        public boolean isViewFromObject(View arg0, Object arg1) {
            // TODO Auto-generated method stub
            return arg0==arg1;
        }
        @Override
        public Object instantiateItem(ViewGroup container, int position) {
//          ImageView iv=new ImageView(getApplicationContext());
//          iv.setImageResource(images[position]);
            TextView iv=new TextView(getApplicationContext());
            iv.setText(title[position]);
            container.addView(iv);
            return iv;
        }
        @Override
        public void destroyItem(ViewGroup container, int position, Object object) {
            container.removeView((View) object);
        }

        /* (non-Javadoc)
         * @see android.support.v4.view.PagerAdapter#getPageTitle(int)
         */
        @Override
        public CharSequence getPageTitle(int position) {
            // TODO Auto-generated method stub
            return title[position];
        }

    }
}

<?xml version="1.0" encoding="utf-8"?>
package="com.itheima.tab"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme"
    >
    <activity
        android:name="com.itheima.tab.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".HomeActivity"
         android:theme="@style/Theme.PageIndicatorDefaults"
        ></activity>
</application>

图片说明

tab

1个回答

我今天也遇到了同样的问题,你只需要将你这个页面的根部局设置背景色为白色即可:android:background="#ffffff"
<?xml version="1.0" encoding="utf-8"?>
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#ffffff"
>

<include layout="@layout/title_bar"/>

<!--<ListView-->
    <!--android:id="@+id/collection_lv"-->
    <!--android:layout_width="match_parent"-->
    <!--android:layout_height="match_parent"-->
    <!--/>-->

<com.viewpagerindicator.TabPageIndicator
    android:id="@+id/sc_indicator"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>

<android.support.v4.view.ViewPager
    android:id="@+id/vp_sc"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐