Java 如何禁用布局对齐?
我正在尝试将eclipse中的一组对象与android插件对齐。它们都互相链接,这在我更改框中的文本时是有问题的。如何更改自动对齐方式?将所有android:layout…=“”设置为“false”?这是xml文件Java 如何禁用布局对齐?,java,android,graphics,Java,Android,Graphics,我正在尝试将eclipse中的一组对象与android插件对齐。它们都互相链接,这在我更改框中的文本时是有问题的。如何更改自动对齐方式?将所有android:layout…=“”设置为“false”?这是xml文件 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_wi
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<CheckBox
android:id="@+id/chckBxContd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="@+string/RunContd"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/lblUke"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/chckBxContd"
android:layout_centerHorizontal="true"
android:layout_marginTop="25dp"
android:text="@+string/lblUke"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="@+id/btnCUke"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/lblUke"
android:layout_marginLeft="27dp"
android:layout_toRightOf="@+id/lblUke"
android:text="@+string/btnCUke" />
<Button
android:id="@+id/btnGUke"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/btnCUke"
android:layout_alignBottom="@+id/btnCUke"
android:layout_marginRight="20dp"
android:layout_toLeftOf="@+id/lblUke"
android:text="@+string/btnGUke" />
<Button
android:id="@+id/btnEUke"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/btnGUke"
android:layout_below="@+id/btnGUke"
android:layout_marginTop="32dp"
android:text="@+string/btnEUke" />
<Button
android:id="@+id/btnAUke"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/btnEUke"
android:layout_alignBottom="@+id/btnEUke"
android:layout_alignLeft="@+id/btnCUke"
android:text="@+string/btnAUke" />
<TextView
android:id="@+id/lblGuitar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@+string/lblGuitar"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="@+id/btnDGuitar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/btnAUke"
android:layout_below="@+id/lblGuitar"
android:layout_marginTop="19dp"
android:text="@+string/btnDGuitar" />
<Button
android:id="@+id/btnAGuitar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/btnDGuitar"
android:layout_alignBottom="@+id/btnDGuitar"
android:layout_toRightOf="@+id/btnGUke"
android:text="@+string/btnAGuitar" />
<Button
android:id="@+id/btnLowEGuitar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/btnAGuitar"
android:layout_alignBottom="@+id/btnAGuitar"
android:layout_alignRight="@+id/btnEUke"
android:text="@+string/btnLowEGuitar" />
<Button
android:id="@+id/btnGGuitar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/btnLowEGuitar"
android:layout_below="@+id/btnLowEGuitar"
android:layout_marginTop="24dp"
android:text="@+string/btnGGuitar" />
<Button
android:id="@+id/btnBGuitar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/btnGGuitar"
android:layout_alignBottom="@+id/btnGGuitar"
android:layout_centerHorizontal="true"
android:text="@+string/btnBGuitar" />
<Button
android:id="@+id/btnHighEGuitar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/btnBGuitar"
android:layout_alignRight="@+id/btnDGuitar"
android:text="@+string/btnHighEGuitar" />
这就是我希望它看起来的样子,文本是对象。。。
这是程序外观的图片,它还有一些按钮,当它们应该说字母时,会说false,不确定这是关于什么的。这个问题是当文本更改时,布局正在调整宽度 一种可能的解决方案是将
表格布局
与表格行
结合使用。TableLayouts将以相同的方式将所有内容对齐。当内部文本更改时,行大小将保持不变
也可以对每行使用LinearLayout
。将weightSum
属性设置为任意数字。将每个TextView
(或LinearLayout
中的任何直接子项)weight
属性设置为weightSum的一半。无论文本是什么,LinearLayout
将使容器保持相同的大小
事实上,TableLayout扩展了LinearLayout,这就是它背后的基本机制。它们最终应该如何对齐?如果你的
TextView
越来越广泛,你可以使用maxWidth
我的问题是所有东西都在传播,包括按钮,而不仅仅是TextView。如果我能以某种方式删除关系,并将对象放在我想要的地方,问题就会解决。也许你应该发布一张显示其外观的图形。如果希望所有项目彼此相邻,请使用orientation=horizontal
的LinearLayout
。如果您希望每个项目都具有相同的宽度,请查看GridView
(很抱歉,仍然不确定您试图实现什么),一旦模拟器出现,我将发布它的外观。现在,请查看编辑页面。谢谢这解决了大多数问题!谢谢,我使用了表格布局和表格行。这是我的第一个android程序,如果不是很明显,我很感谢你的帮助,我最终会掌握它的窍门的!