开发者

Tab layout not displaying as I want

开发者 https://www.devze.com 2023-02-23 03:09 出处:网络
I am using custo开发者_运维知识库m background for my Tab layout, but it displaying something different. As

I am using custo开发者_运维知识库m background for my Tab layout, but it displaying something different. As

Tab layout not displaying as I want

but I want as

Tab layout not displaying as I want

and my code is as

for(int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) {
            tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#0079AD"));
            ((TextView) tabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title)).setTextColor(Color.parseColor("#8CD7F2"));
        }
        tabHost.getTabWidget().getChildAt(tabHost.getCurrentTab()).setBackgroundColor(Color.parseColor("#009ED6"));

how can I solve this?


For getting effect as I wan't I am using drawable image as follow and I am getting result as I wan't almost same as your.

ImageView view1;
TabHost tabHost;
tabHost = getTabHost()
TabHost.TabSpec spec;
Intent intent;

view1 = new ImageView(this);
view1.setOnTouchListener(view1Touch);//for identifying touch newly added.
view1.setBackgroundResource(R.drawable.tab_image);
intent = new Intent().setClass(this, AnohterActivity.class);
spec = tabHost.newTabSpec(TAG_1).setIndicator(view1).setContent(
                intent);
tabHost.addTab(spec);

=======================

OnTouchListener view1Touch = new OnTouchListener() {

    @Override
    public boolean onTouch(View v, MotionEvent event) {
        if (event.getAction() == MotionEvent.ACTION_DOWN) {
            v.setBackgroundResource(R.drawable.tab_focus);
        }

}

and TabChangeListener you might be already added.

0

精彩评论

暂无评论...
验证码 换一张
取 消