android-最后添加到布局中的项目是strech垂直。为什么?(翻拍)
[第二次编辑] 我找到了问题所在。但我不知道它为什么这么做。它不能是线性布局上的边距(或仅边距左侧)。有人知道为什么它不能有吗 [编辑] 您好我的xml文件布局如下。我正在将任何xml布局中的文本视图添加到水平线性布局中。此布局结构已给定,我无法更改。 最后添加的TextView总是垂直分布。我不知道为什么我完全绝望了。我尝试了太多的时间,但我不知道。我知道只是它不在程序中添加文本视图。。 如果有人知道这是为什么,我会心存感激android-最后添加到布局中的项目是strech垂直。为什么?(翻拍),android,layout,fill,Android,Layout,Fill,[第二次编辑] 我找到了问题所在。但我不知道它为什么这么做。它不能是线性布局上的边距(或仅边距左侧)。有人知道为什么它不能有吗 [编辑] 您好我的xml文件布局如下。我正在将任何xml布局中的文本视图添加到水平线性布局中。此布局结构已给定,我无法更改。 最后添加的TextView总是垂直分布。我不知道为什么我完全绝望了。我尝试了太多的时间,但我不知道。我知道只是它不在程序中添加文本视图。。 如果有人知道这是为什么,我会心存感激 <RelativeLayout android:layou
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/back_border"
>
<RelativeLayout
android:id="@+id/manager_view_table_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
>
<LinearLayout
android:id="@+id/layout_for_textViews"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="6px"
android:layout_alignParentTop="true"
android:gravity="center_vertical"
android:background="@drawable/back_border"
>
<!-- horizontal layout, HERE IAM ADDING TEXTVIEWS -->
</LinearLayout>
</RelativeLayout>
<!--What is here its no important
because, there is RelativeLayout with alignBellow relative layout before -->
</RelativeLayout>
和文本视图开关iam添加到线性布局:
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:paddingRight="7px"
android:paddingLeft="7px"
android:paddingTop="3px"
android:paddingBottom="3px"
android:layout_marginLeft="5px"
android:gravity="center_horizontal"
android:background="@drawable/background_table"
android:textColor="#330033"
android:text="Some text"
/>
我对你的三种布局感到困惑。这是所有嵌套布局的位置,尝试使用单个相对布局重新创建文本视图,并使用上面的android:layout_和下面的android:layout_放置文本视图。我对您的三个布局感到困惑。这是所有嵌套布局的位置,尝试使用单个相对布局重新创建文本视图,并使用上面的android:layout_和下面的android:layout_放置文本视图。首先,您需要重构此代码
您可能希望使用实际的ListView
来创建重复的元素
为什么xmlns:android=”http://schemas.android.com/apk/res/android“
在这段xml代码中声明了三次,而实际上只需要在顶部根元素声明一次
即使使用此布局来解决您的问题,如果其他方面不起作用,最好切换到图形布局(打开.xml文件时,eclipse中的底部选项卡)并手动尝试设置第三个
文本视图(而不是listview)
高度,然后,您可以观察更改并相应地完成它们。首先,您需要重构此代码
您可能希望使用实际的ListView
来创建重复的元素
为什么xmlns:android=”http://schemas.android.com/apk/res/android“
在这段xml代码中声明了三次,而实际上只需要在顶部根元素声明一次
即使使用此布局来解决您的问题,如果其他方面不起作用,最好切换到图形布局(打开.xml文件时,eclipse中的底部选项卡)并手动尝试设置第三个
文本视图(而不是listview)高度,然后,您可以观察更改并相应地完成更改。尝试将线性布局中的android:layout_margin=“6px”替换为android:padding=“6px”。
我想这会解决你的问题。我的意思是,新的线性布局应该是这样的:
<LinearLayout
android:id="@+id/layout_for_textViews"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="6px"
android:layout_alignParentTop="true"
android:gravity="center_vertical"
android:background="#44ff435f"
>
尝试用android:padding=“6px”替换线性布局中的android:layout\u margin=“6px”。
我想这会解决你的问题。我的意思是,新的线性布局应该是这样的:
<LinearLayout
android:id="@+id/layout_for_textViews"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="6px"
android:layout_alignParentTop="true"
android:gravity="center_vertical"
android:background="#44ff435f"
>
为什么有三种封闭式布局?您在说什么ListView?我在你发布的xml中没有看到一个。。没有ListView,只有TextView。。它们是封闭的,因为它只是我的主xml的一部分。我是说,其他事情并不重要。对不起,我的问题很糟糕。我去重写它。。见上面的帖子为什么你们有三个封闭的布局?你们在说什么ListView?我在你发布的xml中没有看到一个。。没有ListView,只有TextView。。它们是封闭的,因为它只是我的主xml的一部分。我是说,其他事情并不重要。对不起,我的问题很糟糕。我去重写它。。请参阅上面的帖子,我无法重构此代码。。我编辑它是为了更好地理解post:p。。sry请检查一下。我正在使用netbeans,但我会在图形布局上找到一些东西来显示它,所以我无法重构此代码。。我编辑它是为了更好地理解post:p。。sry请检查一下。我正在使用netbeans,但我找到了一些东西在图形布局上显示它,在这三个布局周围,它的其他视图并不重要,抱歉我的公式化问题不好,我将其重写为更好。我已将线性布局更改为相对布局,但没有任何变化,而在这三个布局周围,它的其他视图,这并不重要,对不起,对于我糟糕的公式化问题,我将其改写为更好的。我已将线性布局更改为相对布局,但没有任何更改是的,它只是边缘左侧,它的到来比最后一项的拉伸不具吸引力,可能是因为textView有边缘左侧,但问题仍然是为什么?是的,它只是边缘左侧,它的到来比上一个项目更不吸引人,可能是因为textView有边际效果,但问题是为什么?