0
給每個人都帶來歡樂。相對佈局重疊
當我碰到一個重疊問題時,我正在研究一個簡單的自定義ArrayAdapter。
這是我的佈局XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="@+id/label" />
<EditText
android:id="@+id/editText"
android:hint="0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="4dp"
android:layout_marginRight="10dp">
</EditText>
</RelativeLayout>
的問題是,如果標籤太長,它重疊的EditText元素。
我也嘗試過使用帶重量的水平佈局,但當標籤太長時,edittext會跳出屏幕。
我已經閱讀了6篇關於相對佈局重疊的文章,但似乎沒有任何工作。
設置固定寬度而不是包裝內容 – Pragnani 2013-02-11 18:43:00
但是如何獲得隨屏幕尺寸而變化的值? – Kohakukun 2013-02-15 23:40:13
你爲什麼要煩擾屏幕尺寸?你正在使用'dp(密度獨立像素)'來命名它自己表明該值將在屏幕大小上發生變化。如果您對此有任何疑問,請參閱http://stackoverflow.com/questions/2025282/difference-of- px-dp-dip-and-sp-in-android參考 – Pragnani 2013-02-16 05:13:28