Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/200.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 当应用程序从后台返回时,为什么tabbar会向下移动几个像素?_Android_Background_Tabbar_Shift - Fatal编程技术网

Android 当应用程序从后台返回时,为什么tabbar会向下移动几个像素?

Android 当应用程序从后台返回时,为什么tabbar会向下移动几个像素?,android,background,tabbar,shift,Android,Background,Tabbar,Shift,代码如下: 公共类MenuTableActivity扩展了TabActivity实现OnTabChangeListener{ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.menu_layout); TabHost tb = getTabHost(); T

代码如下:

公共类MenuTableActivity扩展了TabActivity实现OnTabChangeListener{

@Override   
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.menu_layout);

    TabHost tb = getTabHost();

    TabHost.TabSpec spec = null;
    Intent intent = null;

    // My Profile tab
    intent = new Intent(this, MyProfileActivityGroup.class);

    View myProfileView = LayoutInflater.from(this).inflate(R.layout.button_profil, null);
    spec = tb.newTabSpec("0").setIndicator(myProfileView).setContent(intent);
    tb.addTab(spec);

    // Driving tab
    intent = new Intent(this, DrivingActivityGroup.class);
    View drivingView = LayoutInflater.from(this).inflate(R.layout.button_conduite, null);
    spec = tb.newTabSpec("1").setIndicator(drivingView).setContent(intent);
    tb.addTab(spec);

    // Score Tab
    intent = new Intent(this, ScoreActivityGroup.class);
    View scoreView = LayoutInflater.from(this).inflate(R.layout.button_score, null);
    spec = tb.newTabSpec("2").setIndicator(scoreView).setContent(intent);
    tb.addTab(spec);

    // Advices Tab
    intent = new Intent(this, AdvicesActivity.class);
    View advicesView = LayoutInflater.from(this).inflate(R.layout.button_conseils, null);
    spec = tb.newTabSpec("3").setIndicator(advicesView).setContent(intent);

    tb.addTab(spec);
    tb.setOnTabChangedListener(this);
    Main.tabBar = tb;
    tb.setCurrentTab(0);
}

@Override
public void onTabChanged(String tabId) {

    if (tabId.equals("2")){

        //refresh third tab
        ((ScoreActivityGroup)(getLocalActivityManager().getActivity(tabId))).getScoreActivity().updateView();
    }

    if (tabId.equals("1")){ //driving activity

        if (Utils.tabImage == null) {

            //create the static image of the tabbar here
            Bitmap tabImage = Bitmap.createBitmap(getTabHost().getTabWidget().getWidth(), getTabHost().getTabWidget().getHeight(), Bitmap.Config.RGB_565);
            getTabHost().getTabWidget().draw(new Canvas(tabImage));
            Utils.tabImage = tabImage;
        }

        //load second "tab" Activity
        ((DrivingActivityGroup)(getLocalActivityManager().getActivity("1"))).startDrivingActivity();
    }

    if (!tabId.equals("2")){

        if (getLocalActivityManager().getActivity("2") != null){

            if (((ScoreActivityGroup)getLocalActivityManager().getActivity("2")).getCurrentActivity() instanceof ScoreDetailsActivity){

                //dismiss Conseil Dialog if it exists
                ((ScoreDetailsActivity)(((ScoreActivityGroup)getLocalActivityManager().getActivity("2")).getCurrentActivity())).dismissConseilDialog();
            }
        }
    }
}

/**
 * This method starts an activity with a given animation (ex: bottom-top)
 * Used for info activities
 * 
 * This action is placed here because the animations are ignored if done
 * from child activities of the MenuTabActivity.
 * 
 * @param clazz
 * @param enterAnim
 * @param exitAnim
 * @param intentExtra
 */
public void startActivityWithOverridePendingTransition(Class<?> clazz, int enterAnim, int exitAnim, Integer intentExtra){
    final Intent intent = new Intent(this, clazz);
    if ( intentExtra !=  null ){
        intent.putExtra("com.renault.Intent", intentExtra);
    }
    startActivity(intent);
    overridePendingTransition(enterAnim, exitAnim);
}

public void onDestroy(){
    super.onDestroy();

    if (Main.monitoringHasStarted) {

        Main.DriveBusinessService.stopMonitoring();
        ScoringModelPojo.saveToBundle(getApplicationContext());
    }

    Main.monitoringHasStarted = false;

    SettingsModel.saveToBundle(getApplicationContext());
}
} `

以下是tabwidget:

<?xml version="1.0" encoding="utf-8"?>
<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">
    <LinearLayout
        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"/>
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background = "@color/grayFond" 
            android:layout_weight = "0"/>
    </LinearLayout>
</TabHost>

你们有谁遇到过标题中提到的问题吗?

我发现了问题所在。里面一定是个虫子。在清单文件中,我没有状态栏和全屏。当将状态栏重新引入屏幕时,它不会全屏工作。也许这对某人有帮助


顺便说一句,这应该作为一个错误提交给ANDROID。在2.1中测试您想知道什么?标题中明确说明了问题。你的困惑在哪里?最初你没有发布你的代码,所以也只发布代码。但问题很可能出在xml布局中