2013-11-24 24 views
18

これは私のres/layout mobile.xmlファイルです。私のミスはどこですか? textviewを実行すると、このエラーが発生します。エラー: 'android'パッケージの 'textAlignment'属性のリソース識別子が見つかりません

<?xml version="1.0" encoding="utf-8"?> 
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:padding="5dp" > 
    <ImageView 
    android:id="@+id/grid_item_image" 
    android:layout_width="100dp" 
    android:layout_height="118dp" 
    android:src="@drawable/android_logo" > 
    </ImageView> 
    <TextView 
    android:id="@+id/grid_item_label" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="15dp" 
    android:text="@+id/label" 
    android:textSize="25dp" 
    android:textAlignment="center" > 
    </TextView> 
    </LinearLayout> 

答えて

0

私は問題は、この行に何ができるかを考える:

android:text="@+id/label" 

はこれを試してみてください。

android:text="@string/label" 
48

textAlignmentはAPIレベル17(アンドロイド4.2)で追加されました。

エミュレータ/デバイスが動作するには、4.2 +を実行する必要があります。

そうでない場合は、単にこれが正解であるandroid:gravity="center"

<TextView 
    android:id="@+id/grid_item_label" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="15dp" 
    android:text="@+id/label" 
    android:textSize="25dp" 
    android:gravity="center" /> 
+1

を使用しています。 –

関連する問題