今天就跟大家聊聊有關MarginLeft與MarginStart在Android中的區別是什么,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結了以下內容,希望大家根據這篇文章可以有所收獲。
我們在寫layout布局的時候,我們會發現有這樣幾個比較相似的屬性:
MarginStart MarginLeft
MarginEnd MarginRight
這些屬性的區別是什么? 根據api注釋,我們得知MarginStart指的是控件距離開頭View部分的間距大小,MarginLeft則指的是控件距離左邊View部分的間距大小,MarginEnd和MarginRight同理。
一般情況下,View開始部分就是左邊,但是有的語言目前為止還是按照從右往左的順序來書寫的,例如阿拉伯語,在Android 4.2系統之后,Google在Android中引入了RTL布局,更好了支持了由右到左文字布局的顯示,為了更好的兼容RTL布局,google推薦使用MarginStart和MarginEnd來替代MarginLeft和MarginRight,這樣應用可以在正常的屏幕和由右到左顯示文字的屏幕上都保持一致的用戶體驗。
<RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <Button android:onClick="cancle" android:id="@+id/cancel" android:layout_width="100dp" android:layout_height="wrap_content" android:layout_alignParentStart="true" android:layout_alignParentTop="true" android:layout_marginStart="75dp" android:text="取消" /> <Button android:onClick="query" android:id="@+id/query" android:layout_width="100dp" android:layout_height="wrap_content" android:layout_alignParentEnd="true" android:layout_alignParentTop="true" android:layout_marginEnd="49dp" android:text="確定" /> </RelativeLayout>
看完上述內容,你們對MarginLeft與MarginStart在Android中的區別是什么有進一步的了解嗎?如果還想了解更多知識或者相關內容,請關注億速云行業資訊頻道,感謝大家的支持。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。