【问题标题】:How to remove default spacing between textviews android如何删除textviews android之间的默认间距
【发布时间】:2013-04-26 21:51:15
【问题描述】:

Answer ::: 用于 TextView 3 和 4 的 android:layout_marginTop="-5dp"

我有两个线性布局(水平),每个布局有两个文本视图。

文本视图1文本视图2

TextView3 TextView4

我得到了这些 LinearLayout 之间的默认间距,这是我不想要的。我希望 textviews 3 和 4 出现在 1 和 2 的正下方。我如何得到它?

外部布局是相对布局

XML

<LinearLayout 
        android:id="@+id/ll1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_below="@id/img"
        android:paddingLeft="5dp"
        android:paddingRight="5dp" >

        <TextView
        android:id="@+id/imp"
        android:layout_width="0dip"
        android:layout_weight="0.80"
        android:layout_height="wrap_content"        
        android:text="@string/xyzs"
        android:textColor="#808080"
        android:textIsSelectable="false"
        android:textSize="10sp"
        android:gravity="left" />

        <TextView
        android:id="@+id/impr"
        android:layout_width="0dip"
        android:layout_weight="0.20"
        android:layout_height="wrap_content"        
        android:text="@string/xyz2"
        android:textColor="#545454"
        android:textIsSelectable="false"
        android:textSize="10sp"
        android:textStyle="bold"
        android:gravity="right" />


    </LinearLayout>

    <LinearLayout 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_below="@id/ll1"
        android:paddingLeft="5dp"
        android:paddingRight="5dp" >


    <TextView
        android:id="@+id/v"
        android:layout_width="0dip"
        android:layout_weight="0.80"
        android:layout_height="wrap_content"        
        android:text="@string/xyz3"
        android:textColor="#747474"
        android:textIsSelectable="false"
        android:textSize="10sp"
        android:gravity="left" />

    <TextView
        android:id="@+id/vo"
        android:layout_width="0dip"
        android:layout_weight="0.20"
        android:layout_height="wrap_content"        
        android:text="@string/xyz4"
        android:textColor="#545454"
        android:textIsSelectable="false"
        android:textSize="10sp"
        android:textStyle="bold"
        android:gravity="right" />
    </LinearLayout>

【问题讨论】:

  • 然后使用相对布局
  • 尝试从 TextViews 中移除重力属性

标签: android


【解决方案1】:

尝试在 TextView 3 和 TextView 4 上使用负边距。

android:layout_marginTop="-10dp"

【讨论】:

    猜你喜欢
    • 2023-02-10
    • 2016-04-12
    • 2020-02-26
    • 2015-01-20
    • 2017-03-09
    • 1970-01-01
    • 1970-01-01
    • 2016-05-08
    • 2013-08-01
    相关资源
    最近更新 更多