【问题标题】:android TextView remove implicit marginsandroid TextView 删除隐式边距
【发布时间】:2012-10-27 13:55:15
【问题描述】:

嗯,这就是我得到的:

这就是我想要的:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent" >

  <TextView
      android:layout_alignParentLeft="true"
      android:layout_alignParentTop="true"
      android:text="3"
      android:textSize="500px"
      android:includeFontPadding="false"
      android:paddingTop="0px"
      android:paddingBottom="0px"
      android:paddingLeft="0px"
      android:paddingRight="0px"
      android:layout_marginTop="0px"
      android:layout_marginBottom="0px"
      android:layout_marginLeft="0px"
      android:layout_marginRight="0px"
      android:background="@null"
      android:layout_width="match_parent"
      android:layout_height="match_parent" >
  </TextView>
</RelativeLayout>

如您所见,我使用了所有已知的魔法:includeFontPaddingbackground="@null"、边距、填充等。我错过了什么吗?

【问题讨论】:

  • 尝试使用线性布局并在其中放置文本视图

标签: android margin textview


【解决方案1】:

尝试将高度和宽度赋予wrap_contant 而不是match_parent

【讨论】:

    【解决方案2】:

    你可以使用

     <TextView 
            android:id="@+id/text1" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:text="3" 
            android:textSize="500px" 
    android:background="@null"
            android:paddingTop="0px" 
            android:gravity="top">
    
        </TextView> 
    

    【讨论】:

    • 你在设备上测试过吗?它对我没有帮助。我有一台运行 Android 4.1.2 的 Google Nexus 7。
    • 没有。我没有在设备上测试过。
    猜你喜欢
    • 2012-01-17
    • 2015-08-27
    • 2014-06-07
    • 1970-01-01
    • 2013-12-25
    • 1970-01-01
    • 2012-07-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多