Java 在Android中更改TableLayout中TextView和列的文本大小
如您所见,我正在尝试拉伸文本框,使其位于“NOPE”按钮旁边。我受到列大小和文本框大小的限制,我不知道如何更改 XML:Java 在Android中更改TableLayout中TextView和列的文本大小,java,android,layout,text,Java,Android,Layout,Text,如您所见,我正在尝试拉伸文本框,使其位于“NOPE”按钮旁边。我受到列大小和文本框大小的限制,我不知道如何更改 XML: 如果您使用dp设置硬代码的宽度,它将无法在多屏幕上正常工作。我不知道你测试应用程序的屏幕大小。。您可以设置TextViewandroid:layout\u width=“100dp”我希望它对您有用 但最好的是 您可以在TableRow中设置android:weightSum,并在TableRow下设置android:layout\u weight视图。。。下面的代码是为
如果您使用
dp
设置硬代码的宽度,它将无法在多屏幕上正常工作。我不知道你测试应用程序的屏幕大小。。您可以设置TextView
android:layout\u width=“100dp”
我希望它对您有用
但最好的是
您可以在TableRow
中设置android:weightSum
,并在TableRow
下设置android:layout\u weight
视图。。。下面的代码是为您完成的。它将适合所有屏幕大小
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightSum="10">
<Button
android:id="@+id/editBtn"
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="36dp"
android:layout_column="2"
android:layout_weight="2"
android:onClick="editEvent"
android:text="EDIT" />
<TextView
android:id="@+id/attendingEventInListviewRow"
android:layout_width="0dp"
android:layout_weight="6"
android:layout_height="wrap_content"
android:layout_column="38"
android:height="30sp"
android:tag="Events2goName"
android:text="Events2go"
android:textColor="#000000"
android:textSize="22sp"
android:textStyle="normal" />
<Button
android:id="@+id/cancel_arrive"
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="36dp"
android:layout_column="37"
android:layout_gravity="right"
android:layout_weight="0.08"
android:onClick="selectCancelArrive"
android:text="Nope" />
</TableRow>
如果您使用
dp
设置硬码宽度,它将无法在多屏幕上正常工作。我不知道你测试应用程序的屏幕大小。。您可以设置TextView
android:layout\u width=“100dp”
我希望它对您有用
但最好的是
您可以在TableRow
中设置android:weightSum
,并在TableRow
下设置android:layout\u weight
视图。。。下面的代码是为您完成的。它将适合所有屏幕大小
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightSum="10">
<Button
android:id="@+id/editBtn"
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="36dp"
android:layout_column="2"
android:layout_weight="2"
android:onClick="editEvent"
android:text="EDIT" />
<TextView
android:id="@+id/attendingEventInListviewRow"
android:layout_width="0dp"
android:layout_weight="6"
android:layout_height="wrap_content"
android:layout_column="38"
android:height="30sp"
android:tag="Events2goName"
android:text="Events2go"
android:textColor="#000000"
android:textSize="22sp"
android:textStyle="normal" />
<Button
android:id="@+id/cancel_arrive"
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="36dp"
android:layout_column="37"
android:layout_gravity="right"
android:layout_weight="0.08"
android:onClick="selectCancelArrive"
android:text="Nope" />
</TableRow>
试试这个
<TextView
android:id="@+id/attendingEventInListviewRow"
android:layout_width="0dp"
android:layout_weight=""
android:layout_height="wrap_content"
android:layout_column="38"
android:height="30sp"
android:tag="Events2goName"
android:text="Events2go"
android:textColor="#000000"
android:textSize="22sp"
android:textStyle="normal" />
试试这个
<TextView
android:id="@+id/attendingEventInListviewRow"
android:layout_width="0dp"
android:layout_weight=""
android:layout_height="wrap_content"
android:layout_column="38"
android:height="30sp"
android:tag="Events2goName"
android:text="Events2go"
android:textColor="#000000"
android:textSize="22sp"
android:textStyle="normal" />
例如,如果您有3列(100%权重),并且您希望第一列使用总权重的40%,请输入android:layout\u weight=“0.4”
,如果第二列使用50%的输入android:layout\u weight=“0.5”
并且第三列和最后一列使用10%的默认值android:layout\u weight=“0.1”
,如果您有3列(100%权重),并且希望第一列使用总权重的40%,请输入android:layout\u weight=“0.4”
,如果第二列使用50%的输入android:layout\u weight=“0.5”
,第三列和最后一列使用10%的默认值android:layout\u weight=“0.1”
您的TextView
大小固定为200dp,可能会将其更改为0dp并在那里添加android:weight=“1”
吗?按照我所说的,TextView
将占据表格行中所有剩余空间
我已尝试将大小更改为250dp(不添加重量),但它只是按下了“不”扣上按钮。Than Iv'e尝试了你所说的,结果是:该按钮有布局权重和宽度,尝试移除权重,为什么你将布局列设置为37?你的TextView
大小固定为200dp,可能会将其更改为0dp,并在那里添加android:weight=“1”
?按照我所说的,TextView
将占据表格行中的所有剩余空间
我已尝试将大小更改为250dp(不添加重量),它只是按下了“NOPE”按钮。然后Iv'e尝试了你所说的,结果就是:这个按钮有布局的重量和宽度,试着去掉重量,为什么你把布局列设为37?