有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java MarginLeft不起作用:为什么?

我有这个布局

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
    安卓:layout_width="wrap_content"
    安卓:layout_height="wrap_content" >

    <ScrollView
        安卓:layout_width="fill_parent"
        安卓:layout_height="fill_parent">

        <TextView
        安卓:id="@+id/textView2"
        安卓:layout_marginLeft="13dp"
        安卓:layout_marginRight="0dp"
        安卓:layout_marginBottom="0dp"
        安卓:layout_width="fill_parent"
        安卓:layout_height="fill_parent"
        安卓:textSize="16sp"
        安卓:text="@string/text"
        />
</ScrollView>
</RelativeLayout>

我想知道为什么在一些手机或Android版本(主要是2.3姜饼)上,页边距实际上是0,因为它没有与左边距分离,而是附加在一起,好像没有Android:layout_marginLeft=“13dp”


共 (1) 个答案

  1. # 1 楼答案

    在xml中尝试以下内容。我添加了android:layout_gravity="left"

      <TextView
                android:id="@+id/textView2"
                android:layout_marginLeft="13dp"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                 android:layout_gravity="left"
                android:textSize="16sp"
                android:text="text"
                />