为什么Eclipse告诉我没有属性“ margin”?为LinearLayout? [英] Why would Eclipse tell me there is no attribute "margin" for a LinearLayout?
问题描述
当我尝试构建我的android项目时遇到错误:
I'm getting an error when I try and build my android project:
在其中找不到属性'margin'的资源标识符package'android'
No resource identifier found for attribute 'margin' in package 'android'
它将这种布局称为罪魁祸首。但是我找不到任何错误。
And it references this layout as the culprit. But I can't find anything wrong with it.
任何想法为什么Eclipse会认为这些具有边距的视图没有边距?
Any idea why Eclipse would think there is not margin on these views that do have margins ?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="@color/feedstory_background_color"
android:margin="5dp"
android:orientation="vertical"
android:padding="5dp" >
<RelativeLayout
android:id="@+id/feed_profile_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp" >
<ImageButton
android:id="@+id/feed_profileImage"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_alignParentLeft="true"
android:layout_margin="0dp"
android:background="@color/black_bg"
android:maxHeight="60dp"
android:maxWidth="60dp"
android:padding="1dp"
android:scaleType="centerInside"
android:src="@drawable/feed_blank_profile_picture" />
<LinearLayout
android:id="@+id/profile_texts"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_toRightOf="@id/feed_profileImage"
android:orientation="vertical" >
<TextView
android:id="@+id/profile_name_text"
style="@style/feed_profile_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/feed_profile_name" >
</TextView>
<TextView
android:id="@+id/profile_location_text"
style="@style/feed_profile_location"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/feed_profile_location" >
</TextView>
<TextView
android:id="@+id/profile_time_text"
style="@style/feed_profile_time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/feed_profile_time" >
</TextView>
</LinearLayout>
<LinearLayout
android:id="@+id/profile_texts"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:orientation="vertical" >
<Button
android:id="@+id/fan_button"
style="@style/feed_button_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:background="@drawable/red_button"
android:margin="0dp"
android:minHeight="0dip"
android:minWidth="70dip"
android:padding="5dp"
android:text="@string/feed_fan_button" />
<TextView
android:id="@+id/fan_count_text"
style="@style/feed_button_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/grey_button"
android:margin="0dp"
android:minHeight="0dip"
android:minWidth="70dip"
android:padding="5dp"
android:text="000000" >
</TextView>
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:id="@+id/content_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:orientation="vertical" >
<TextView
android:id="@+id/post_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/feed_default_post_text"
style="@style/feed_text_style"
>
</TextView>
</LinearLayout>
<RelativeLayout
android:id="@+id/feedback_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/applaud_button"
style="@style/feed_button_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="2dp"
android:background="@drawable/red_button"
android:minHeight="0dip"
android:minWidth="70dip"
android:text="@string/feed_applaud_button" />
<TextView
android:id="@+id/applaud_count_text"
style="@style/feed_button_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="2dp"
android:layout_toRightOf="@id/applaud_button"
android:background="@drawable/grey_button"
android:margin="10dp"
android:padding="10dp"
android:text="000000" >
</TextView>
<Button
android:id="@+id/comment_button"
style="@style/feed_button_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginRight="2dp"
android:layout_toLeftOf="@+id/comment_count_text"
android:background="@drawable/red_button"
android:minHeight="0dip"
android:text="@string/feed_comment_button" />
<TextView
android:id="@+id/comment_count_text"
style="@style/feed_button_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="2dp"
android:layout_marginTop="0dp"
android:layout_weight="1"
android:background="@drawable/grey_button"
android:text="000000" >
</TextView>
</RelativeLayout>
</LinearLayout>
推荐答案
正确的属性名称,用于在每个属性中声明5p边距方向是:
The correct attribute name for declaring a 5p margin in every direction is:
android:layout_margin="5dp"
请注意 layout _
前缀。您将想要删除显示 android:margin = 5dp
的行,这是Eclipse引起抱怨的原因。
Note the layout_
prefix. You'll want to remove the line that says android:margin="5dp"
, which is what makes Eclipse complain.
全套有效保证金属性包括:
The full set of valid margin attributes includes:
-
layout_margin
-
layout_marginBottom
-
layout_marginEnd
-
layout_marginLeft
-
layout_marginRight
-
layout_marginStart
-
layout_marginTop
layout_margin
layout_marginBottom
layout_marginEnd
layout_marginLeft
layout_marginRight
layout_marginStart
layout_marginTop
这篇关于为什么Eclipse告诉我没有属性“ margin”?为LinearLayout?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!