0

私はmarshmallowデバイスグラジエントを実行したときにactivity_main.xmlにグラジエントを適用しましたが、デバイスグラジエントが適用されていない場合、kitkatデバイスにグラデネットが適用されていません

enter image description here

キットカットUI画面:activity_main.xmlの外観は

マシュマロUI画面好きここれる

enter image description here

をここでactivity_main.xmlのソースコードは、

ここで
<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@drawable/background_gradient" 
android:focusableInTouchMode="true"> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" /> 

</ScrollView> 

は私が

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
android:shape="rectangle"> 
<gradient 
    android:angle="90" 
    android:centerColor="#295e7c" 
    android:centerY="0" 
    android:endColor="#303a70" 
    android:gradientRadius="775dp" 
    android:startColor="#56a68d" 
    android:type="radial" /> 
<corners android:radius="0dp" /> 
</shape> 

答えて

0

からdpを削除してくださいで、マシュマロバージョン。複数のレイアウトを使用している場合は、これらのクラスでこのメソッドを呼び出しても問題はありません。

ssv = (ScrollView) findViewById(R.id.ssv); 

    if (Build.VERSION.SDK_INT <= 22) { 
    GradientDrawable gradientDrawable = new GradientDrawable(
    GradientDrawable.Orientation.TOP_BOTTOM, 
    new int[]{0xFF56a68d, 0xFF295e7c, 0xFF303a70}); 
    gradientDrawable.setCornerRadius(0f); 
    gradientDrawable.setGradientRadius(775f); 
    gradientDrawable.setGradientCenter(0.5f, 0); 
    gradientDrawable.setGradientType(GradientDrawable.RADIAL_GRADIENT); 
    ssv.setBackgroundDrawable(gradientDrawable); 
    } 
0

を使用している勾配コードは、あなたが言ったように私は、コードを実装した、それは両方のキットカットのために良い取り組んでいるgradientRadius

<gradient 
    android:angle="90" 
    android:centerColor="#295e7c" 
    android:centerY="0" 
    android:endColor="#303a70" 
    android:gradientRadius="775" 
    android:startColor="#56a68d" 
    android:type="radial" /> 
+0

私はgradientRadiusを削除しますが、gradientRadiusを削除 – Karthik

+0

@Karthik DONOTを働いていません。値を775dpから775のみに変更します.dpのみを削除します。 – sJy

+0

ええ、私はあなたが言ったようにコードを変更しました、私はkitkatデバイスでうまくいきましたが、マホロジーデバイスではそれは良く見えませんでした。 – Karthik

関連する問題