Button setDefaultViewOptions(Button button) { //назначает начальные настройки кнопке и тексту перегружен (2) button.setText("New button"); button.setLayoutParams(viewParams); button.setId(buttonsId); //теги и id для массива кнопок if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { button.setElevation(20); button.setTranslationZ(10); Log.d("TEST","тестирование"); } String buttonTags = "Button:"; button.setTag(buttonTags + String.valueOf(CountButtonsTags++)); linearLayout.addView(button); buttonsId++; return button; } 

There is a method that assigns starting properties to a button, one of these properties (height above layout) is elevation. But the height does not increase, but the buttons remain the same as it was. Why it happens? All other properties work, the setElevation () method is called.

  • And on what device are you testing? - Flippy

1 answer 1

The default button style in the section has a StateListAnimator , which controls elevation . You can delete an existing animator or set your own using the android:stateListAnimator property.

 <Button ... android:stateListAnimator="@null" /> <Button ... android:stateListAnimator="@anim/my_animator" />