[英]how to disable layout alignments?
我试图将一堆对象与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_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" />
这就是我想要的样子,文字是对象...
这是程序外观的图片,它还具有一些错误的按钮,当他们应该说一个字母时,它们不确定是什么意思。
问题是文本更改时布局正在调整宽度。
可能的解决方案是将TableLayout
与TableRows
结合使用。 TableLayouts将所有内容对齐在一起。 当内部文本更改时,行大小将保持不变。
或者,您可以对每行使用LinearLayout
。 将weightSum
属性设置为任意数字。 将每个TextView
(或LinearLayout
中的任何直接子级) weight
属性设置为weightSum的一半。 无论文本是什么, LinearLayout
都会使容器保持相同的大小。
实际上,TableLayout扩展了LinearLayout,这是其背后的基本机制。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.