Android Studio 建议添加 android:layout_alignLeft 属性但它会破坏布局?
Android Studio recommends adding android:layout_alignLeft property but it breaks layout?
我下面的布局代码使用 android:layout_alignStart
,在 Eclipse 中运行完美。但是,最近我切换到官方 Android Studio。当我在那里使用 alignStart 属性时,Android Studio 用红色波浪线在其下划线并显示 "To support older versions than API 17(project specifies 9) you should also add android:layout_alignLeft="@+id/textview1".
但是,我尝试按照 Android Studio 的建议替换它,但我没有得到 alignStart 应该给出的输出!我试图将 dataView2
放在 textView2
的右侧,但它目前位于 textView2
...
之上
<TextView
android:id="@+id/dataView2"
android:layout_toRightOf="@+id/textView2"
android:layout_alignStart="@+id/dataView1"
android:layout_alignBelow="@+id/dataView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/planet_mass_label" />
由于您的原始代码使用 layout_alignStart="@+id/dataView1"
,因此您应该为 API 17 之前的兼容性添加的行是
android:layout_alignLeft="@+id/dataView1"
没有
android:layout_alignLeft="@+id/textView1"
最终代码应该是
<TextView
android:id="@+id/dataView2"
android:layout_toRightOf="@+id/textView2"
android:layout_alignStart="@+id/dataView1"
android:layout_alignLeft="@+id/dataView1"
android:layout_alignBelow="@+id/dataView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/planet_mass_label" />
目前你的 minSdk 是 9,所以你得到的红线是 "To support older versions than API 17(project specifies 9) you should also add android:layout_alignLeft="@+id/textview1"。
参考这个link:http://android-developers.blogspot.in/2013/03/native-rtl-support-in-android-42.html
如果您希望您的 minSdk 为 9 或小于 17,那么您应该同时使用两者,android:layout_alignLeft="@+id/dataView1"
android:layout_alignStart="@+id/dataView1"
因此。
我下面的布局代码使用 android:layout_alignStart
,在 Eclipse 中运行完美。但是,最近我切换到官方 Android Studio。当我在那里使用 alignStart 属性时,Android Studio 用红色波浪线在其下划线并显示 "To support older versions than API 17(project specifies 9) you should also add android:layout_alignLeft="@+id/textview1".
但是,我尝试按照 Android Studio 的建议替换它,但我没有得到 alignStart 应该给出的输出!我试图将 dataView2
放在 textView2
的右侧,但它目前位于 textView2
...
<TextView
android:id="@+id/dataView2"
android:layout_toRightOf="@+id/textView2"
android:layout_alignStart="@+id/dataView1"
android:layout_alignBelow="@+id/dataView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/planet_mass_label" />
由于您的原始代码使用 layout_alignStart="@+id/dataView1"
,因此您应该为 API 17 之前的兼容性添加的行是
android:layout_alignLeft="@+id/dataView1"
没有
android:layout_alignLeft="@+id/textView1"
最终代码应该是
<TextView
android:id="@+id/dataView2"
android:layout_toRightOf="@+id/textView2"
android:layout_alignStart="@+id/dataView1"
android:layout_alignLeft="@+id/dataView1"
android:layout_alignBelow="@+id/dataView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/planet_mass_label" />
目前你的 minSdk 是 9,所以你得到的红线是 "To support older versions than API 17(project specifies 9) you should also add android:layout_alignLeft="@+id/textview1"。
参考这个link:http://android-developers.blogspot.in/2013/03/native-rtl-support-in-android-42.html
如果您希望您的 minSdk 为 9 或小于 17,那么您应该同时使用两者,android:layout_alignLeft="@+id/dataView1"
android:layout_alignStart="@+id/dataView1"
因此。