Android 5 - 在导航栏上方显示下拉列表的Spinner

4
我在Android编程中遇到了问题 :/ 我已经通过编程方式创建了布局,但是下拉列表的下拉框并不按预期工作...正如你所看到的这里,它们覆盖了底部的导航栏。
仅在Android 5(API级别21)及以上版本中出现此情况。我已经在Android 4.XX上测试过了,它运行良好。
这可能是一个Android的bug吗?
谢谢 :)
PS:这是我的部分代码:
   //--- SPINNER ---
        spinnersArray[j] = new Spinner(getActivity().getApplicationContext());
        spinnersArray[j].setId(j+100); //set a different ID

        //Create the Array that will populate the Spinner, than shuffle it
        Character[] tmpArray = new Character[1 + plaintextCharsArray.length]; 
        tmpArray[0] = ciphertextCharsArray[j]; //first char is a symbol
        Character[] shuffledPlainTextCharsArray = MyUtils.shuffleArray(plaintextCharsArray.clone()); //shuffle a copy of plaintextCharsArray
        for (int i=0; i<plaintextCharsArray.length; i++){
            tmpArray[i+1] = shuffledPlainTextCharsArray[i];
        }

        //Spinner ArrayAdapter 
        final ArrayAdapter<Character> spinnerArrayAdapter = new ArrayAdapter<Character>(
                parentActivity.getApplicationContext(), 
                R.layout.game_controller_fragment_spinner, 
                tmpArray){

                public View getView(int position, View convertView, ViewGroup parent) {
                    View v = super.getView(position, convertView, parent);
                    ((TextView) v).setTypeface(font);   //Set the FONT

                    return v;
                }

                public View getDropDownView(int position, View convertView, ViewGroup parent) {
                    View v = super.getDropDownView(position, convertView, parent);
                    ((TextView) v).setTypeface(font);   //Set the FONT
                    return v;
                }
        };

        //Set the style and the adapter
        spinnerArrayAdapter.setDropDownViewResource(R.layout.game_controller_fragment_spinner_dropdown);
        spinnersArray[j].setBackgroundResource(R.drawable.apptheme_spinner_background_holo_light);
        spinnersArray[j].setAdapter(spinnerArrayAdapter);

        //Find and set the current Spinner selected item
        int h = 0; boolean found = false;
        while ((!found) && (h<tmpArray.length)){
            if (gameArray[j] == tmpArray[h]){
                spinnersArray[j].setSelection(h); //set the Spinner selected item
                found = true;
            }
            h++;
        }

        //Spinner item listener
        spinnersArray[j].setOnItemSelectedListener(new MyItemSelectedListener(tmpArray, j)); 
1个回答

0
主要问题可能有两个,尽管我还没有以编程的方式完成此操作。 我已经遇到过这种情况很多次。
1)确保您的 z 值android:elevation= 是正确的。
2)很多时候,它是在实际的 xml 布局中定义的顺序或相应的编程方式,以及它所包含的布局类型。 在我的经验中,后面定义的项在涉及 z 或高度时优先考虑。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接