버튼의 배경으로 사용되는 레이어 목록의 특정 항목에 setBounds()를 사용하려고합니다. 그러나 findDrawableByLayerId()를 호출하기 위해 LayerDrawable 객체를 가져올 수 없습니다.android에서 findDrawableByLayerId를 사용하는 방법?
는 누구의 도움이 문제를 해결 할 수 있습니까?
버튼의 배경으로 사용되는 레이어 목록의 특정 항목에 setBounds()를 사용하려고합니다. 그러나 findDrawableByLayerId()를 호출하기 위해 LayerDrawable 객체를 가져올 수 없습니다.android에서 findDrawableByLayerId를 사용하는 방법?
는 누구의 도움이 문제를 해결 할 수 있습니까?
는에 만들려면이 방법을 사용하는 새로운 layredrawable : 내가 할 수 소용 filndDrawablebylayerid 없다() :(
@Override
public void setBackgroundDrawable(Drawable background) {
Log.d("button","setting new background ");
Drawable[] layers = new Drawable[5];
Resources resources = getResources();
layers[0] = resources.getDrawable(R.drawable.outer_rectangle);
layers[1] = resources.getDrawable(R.drawable.inner_rectangle);
layers[2] = resources.getDrawable(R.drawable.upper_ovel);
layers[3] = resources.getDrawable(R.drawable.gradient_fill);
layers[4] = resources.getDrawable(R.drawable.lower_ovel);
LayerDrawable layerDrawable = new LayerDrawable(layers);
layerDrawable.setLayerInset(0, 0, 0, 0, 0);
layerDrawable.setLayerInset(1, 3, 3, 3, 0);
layerDrawable.setLayerInset(2, 3, 15, 3, 25);
layerDrawable.setLayerInset(3, 3, 23, 3, 0);
layerDrawable.setLayerInset(4, 4, 60, 4, -5);
super.setBackgroundDrawable(layerDrawable);
}
당신이 findDrawableByLayerId(int id)
을 사용하려는 경우이 아닌 ID가 항상하는 경우, 당신은 처음에 setId(int index, int id)
을 수행해야합니다 -1.