基于Android MarginLeft與MarginStart的區(qū)別(詳解)
我們在寫layout布局的時候,我們會發(fā)現(xiàn)有這樣幾個比較相似的屬性:
MarginStart MarginLeft
MarginEnd MarginRight
這些屬性的區(qū)別是什么? 根據(jù)api注釋,我們得知MarginStart指的是控件距離開頭View部分的間距大小,MarginLeft則指的是控件距離左邊View部分的間距大小,MarginEnd和MarginRight同理。
一般情況下,View開始部分就是左邊,但是有的語言目前為止還是按照從右往左的順序來書寫的,例如阿拉伯語,在Android 4.2系統(tǒng)之后,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" style="@style/common_button_style" 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" style="@style/common_button_style" android:layout_width="100dp" android:layout_height="wrap_content" android:layout_alignParentEnd="true" android:layout_alignParentTop="true" android:layout_marginEnd="49dp" android:text="確定" /> </RelativeLayout>

以上這篇基于Android MarginLeft與MarginStart的區(qū)別(詳解)就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
android app跳轉(zhuǎn)應用商店實現(xiàn)步驟
這篇文章主要為大家介紹了android app跳轉(zhuǎn)應用商店實現(xiàn)步驟詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-11-11
Android Fragment動態(tài)創(chuàng)建詳解及示例代碼
這篇文章主要介紹了Android Fragment動態(tài)創(chuàng)建詳解的相關(guān)資料,并附實例代碼及實現(xiàn)效果圖,需要的朋友可以參考下2016-11-11
Android AlertDialog多種創(chuàng)建方式案例詳解
這篇文章主要介紹了Android AlertDialog多種創(chuàng)建方式案例詳解,本篇文章通過簡要的案例,講解了該項技術(shù)的了解與使用,以下就是詳細內(nèi)容,需要的朋友可以參考下2021-08-08
淺談Android輕量級的數(shù)據(jù)緩存框架RxCache
本篇文章主要介紹了淺談Android輕量級的數(shù)據(jù)緩存框架RxCache,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-08-08

