我试图删除它在 TextView 之前和之后自动创建的空格。怎么可能?
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@drawable/ripetisfondo"
android:padding="1dp" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:shadowColor="#000000"
android:shadowDx="1"
android:shadowDy="1"
android:shadowRadius="2"
android:text="@string/titolo1"
android:textColor="#FFFFFF"
android:textSize="15dp"
android:textStyle="bold" />
<ToggleButton
android:id="@+id/toggleButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
</TableRow>
该屏幕截图取自 Eclipse。当我运行应用程序时,半切换按钮消失。
最佳答案
像这样改变你的 TextView :
android:layout_width="0dp"
android:layout_weight="1"
这将使 TextView 扩展以填充屏幕上的所有其他内容之后的可用空间。这应该让切换占据它需要的空间。
编辑
您可能需要将其包装在 LinearLayout 中才能使其像我建议的那样工作。
关于java - xml中textview前后的空白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10520453/