Venkat Papana
Venkat Papana

Reputation: 4927

Android: android:minSdkVersion=8 causing problem to my button views

I'm using StateListDrawable and LayerDrawable for displaying buttons programatically. It is working fine, but after adding <uses-sdk android:minSdkVersion="8" /> to my manifest file, the buttons are stretched and looking ugly.

Here is my sample code...

Drawable btnNormal = context.getResources().getDrawable(R.drawable.button1);
Drawable btnPrssed = context.getResources().getDrawable(R.drawable.button2); 

Drawable cnLogo = context.getResources().getDrawable(R.drawable.logo);
Drawable rightArrow = context.getResources().getDrawable(R.drawable.arrow);

Drawable[] cnDrawablesNormal = new Drawable[]{btnNormal, cnLogo, rightArrow};
LayerDrawable cnLayersNormal = new LayerDrawable(cnDrawablesNormal);
cnLayersNormal.setLayerInset(1, 10, 1, 250, 1);
cnLayersNormal.setLayerInset(2, 280, 17, 20, 17);  

Drawable[] cnDrawablesPressed = new Drawable[]{btnPrssed, cnLogo, rightArrow};
LayerDrawable cnLayersPressed = new LayerDrawable(cnDrawablesPressed);          
cnLayersPressed.setLayerInset(1, 10, 1, 250, 1);
cnLayersPressed.setLayerInset(2, 280, 17, 20, 17);  

states.addState(new int[] {android.R.attr.state_pressed},cnLayersPressed);
states.addState(new int[] { }, cnLayersNormal); 

I didnt change anything, can anybody explain why it is causing prob, and fix for it.

Thanks in advance.

-venkat papana

Upvotes: 0

Views: 2012

Answers (1)

Mats Hofman
Mats Hofman

Reputation: 7240

I have had a similar problem, I solved it by adding the android:targetSdkVersion value in the AndroidManifest so it will look something like this

<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8" />

Upvotes: 1

Related Questions