2013-11-24 12 views
18

To jest mój plik mobile.xml z res/layout. Gdzie jest mój błąd? Po uruchomieniu textview występuje ten błąd.: Nie znaleziono identyfikatora zasobu dla atrybutu "textAlignment" w pakiecie "android"

<?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> 

Odpowiedz

0

I pomyśleć, co może być problemem w tej linii:

android:text="@+id/label" 

spróbuj tego:

android:text="@string/label" 
48

textAlignment dodano w poziomie API 17 (Android 4.2).

Twój emulator/urządzenie będzie musiało być uruchomione w wersji 4.2+, aby to zadziałało.

W przeciwnym razie po prostu używać 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

To jest prawidłowa odpowiedź. –

Powiązane problemy