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