【问题标题】:Android 5 - Spinner dropdown list over the navigation barAndroid 5 - 导航栏上的微调器下拉列表
【发布时间】:2015-05-18 00:02:35
【问题描述】:

我对 Android 编程有疑问:/
我已经以编程方式创建了一个布局,但微调器的下拉列表不能像方面那样工作...正如您所见 here,它们覆盖了底部的导航栏。

这仅适用于 Android 5(API 级别 21)及更高版本。 我已经在 Android 4.XX 上对此进行了测试,效果很好。

这可能是 Android 错误吗?

谢谢你:)

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)); 

【问题讨论】:

    标签: android spinner android-5.0-lollipop


    【解决方案1】:

    主要问题可能有两个,尽管我没有以编程方式完成此操作。我遇到过很多次了。

    1) 确保您的 z 值 android:elevation= 正确。

    2) 很多时候它是定义的顺序,无论是在实际的 xml 布局中还是以编程方式的等效布局,以及它包含在什么类型的布局中。我的经验是稍后定义的项目在涉及 z 或海拔时优先考虑。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-25
      • 2015-06-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多