【问题标题】:error: No resource identifier found for attribute 'textAlignment' in package 'android'错误:在包“android”中找不到属性“textAlignment”的资源标识符
【发布时间】:2013-12-09 04:04:10
【问题描述】:

这是我的 res/layout mobile.xml 文件。我的错误在哪里?当我运行 textview 时出现此错误。

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

【问题讨论】:

    标签: android xml android-layout


    【解决方案1】:

    textAlignment 在 API 级别 17 (Android 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" />
    

    【讨论】:

      【解决方案2】:

      我认为这行可能有什么问题:

      android:text="@+id/label"
      

      试试这个:

      android:text="@string/label"
      

      【讨论】:

        猜你喜欢
        • 2014-06-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多