java - xml中textview前后的空白

标签 java android xml

enter image description here 我试图删除它在 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/

相关文章:

java - 如何将 TimePicker 时间添加到 BroadCast Receiver 待处理 Intent ?

c# - Nhibernate 非空属性引用空值或 transient 值 Tec.Core.Model.Budget.oInvestmentCode

xml - 使用 xml 扩展 magento 管理

java - 将效果应用于高清图像

java - 如何实现 JTable 单元格更改的事件处理程序

java - 仅运行一次 junit 设置方法

java - 从父 Activity 中获取 fragment 中不同字段的值

java - ComperatorFactory 使用静态方法还是每个方法都在自己的类中?

java - IllegalAccessError 运行 android 仪器测试

Java XML API 将“转换为”