12

Nexus 5 で Android L Preview をテストしています。アプリに問題があります。

背景が設定されたいくつかの TextViews があります。

android:background="@drawable/rounded_textview"

そして、「rounded_textview」は単なる形状です。<=API19以下ではうまく機能しています。

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="3dp">
<solid android:color="#999999"/>
<corners
 android:bottomRightRadius="2dp"
 android:bottomLeftRadius="2dp"
 android:topLeftRadius="2dp"
 android:topRightRadius="2dp"/>
</shape>

Android L Developer Preview では、背景は無視されます。私のすべての TextViews は透明です。私は何が間違っているのですか?

4

2 に答える 2

36

シェイプをセレクターとアイテムタグでラップすると機能することがわかりました

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">

            <solid android:color="@color/gray" />

            <corners
                android:bottomLeftRadius="3dp"
                android:topRightRadius="3dp"
                android:topLeftRadius="3dp"
                android:bottomRightRadius="3dp" />

        </shape>
    </item>
</selector>
于 2014-06-27T02:01:12.937 に答える
0

android:radius のみを使用し、各コーナー オプションは使用しません。私も同じ問題を抱えていましたが、この方法で問題を解決できました。

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="3dp">
<solid android:color="#999999"/>
  <corners android:radius="2dp"/>
</shape>
于 2014-06-27T01:59:05.877 に答える