2012-06-01 14 views
22

に次の点線のXMLにShapeDrawableとして定義され、破線、次のとおりです。Androidのは、ライン描画可能な潜在的なICSのバグ

<shape 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="line"> 

    <size 
     android:height="2dp" 
     android:width="700dp" /> 

    <stroke 
     android:width="1dp" 
     android:color="@android:color/black" 
     android:dashWidth="1dp" 
     android:dashGap="2dp" /> 

</shape> 

これは、いくつかのジンジャーブレッドの携帯電話上の素敵な点線を描画します。しかし、ギャラクシーネクサスでは、ダッシュは無視され、形状は連続した線として描かれています。さらに興味深いことに、ICSを実行しているエミュレータは、ダッシュで正しくレンダリングします。物理的なデバイスが壊れているだけです。

明らかなものがありませんか?それともAndroid 4.0のバグですか?このラインはいくつかの場所で使用されています。ここでは例のImageViewのは、次のとおりです。

<ImageView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginLeft="@dimen/observation_observe_side_margin" 
    android:layout_marginRight="@dimen/observation_observe_side_margin" 
    android:layout_marginTop="16dp" 
    android:contentDescription="@string/dotted_line_description" 
    android:src="@drawable/dotted_line" /> 
+0

Galaxy Nexusのアプリで同じ問題が発生しています。私の他のデバイス2.xデバイスでは、ドット付きで表示されます。 –

+0

duplicate of http://stackoverflow.com/a/26296229/185022 –

+0

可能な複製[実際のAndroid搭載端末でアプリが実行されているときに点線は実際に点滅しません](http://stackoverflow.com/questions/18931679/dotted実際にアンドロイドデバイスで実行中の場合は実際には点滅しません) –

答えて

21

この問題は、ハードウェアアクセラレーションをオフにするhttp://code.google.com/p/android/issues/detail?id=29944ここに記録されることは点線が表示されます。

view.setLayerType(View.LAYER_TYPE_SOFTWARE, null) 

これは私の仕事:

+2

残念ながら、これは私のパフォーマンスを約500%悪化させます。これを防止するための回避策はありますか? –

43

http://code.google.com/p/android/issues/detail?id=29944でログイン問題は、あなたのビューに以下を適用したコメントがあります。

+27

ビューをプログラムで編集したくない場合は、属性 'android:layerType = "software"をXML定義に追加することもできます。 – Arkaaito

+0

API 11+ http://developer.android.com/reference/android/view/View.html#setLayerType – Dori

+0

この質問の例ではそうです。 'android:layerType =" software "'を 'ImageView'や' shape'に設定しますか? –

関連する問題