簡體   English   中英

MarginLeft無效:為什么?

[英]MarginLeft doesn't work: Why?

我有這個布局

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

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

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

我想知道為什么在某些手機或Android版本(主要是2.3 Gingerbread)上,邊距通常不為0,就意味着它沒有與左邊距分離,而是被附加了,就好像沒有android:layout_marginLeft = “ 13dp”

嘗試將android:layout_gravity="left"到您的android:layout_gravity="left" layout_gravity的值可以是任何有效列表。

在您的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"
            />

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM