【发布时间】:2014-01-12 14:43:57
【问题描述】:
在布局上我有列表视图
<com...DynamicListView
android:id="@+id/listview"
android:layout_width="fill_parent"
android:layout_height="5dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:layout_weight="0.34"
android:background="#0000"
android:divider="@null"
android:dividerHeight="5dp" />
添加了第 4 个 TextView。 text_view.xml
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="60dp"
android:gravity="center"
android:textColor="#000000"
android:textSize="@dimen/list_text_size" />
我怎样才能使它们都具有相同的高度并在不同分辨率的屏幕上爬到屏幕上(没有滚动的外观)?
更新
public class StableArrayAdapter extends ArrayAdapter<String> {
public StableArrayAdapter(Context context, int textViewResourceId, List<String> objects) {
super(context, textViewResourceId, objects);
for (int i = 0; i < objects.size(); ++i) {
mIdMap.put(objects.get(i), i);
}
}
...
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = super.getView(position, convertView, parent);
...
int myDPValue = 60;
myDPValue = (int) ((int) myDPValue * Resources.getSystem().getDisplayMetrics().density);
(LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, myDPValue);
view.setLayoutParams(params);
return view;
}
}
【问题讨论】:
-
你在说什么? 他们是谁?
-
列表视图中的项目(文本视图)
-
您的问题不清楚。请清楚地询问您想要什么(可能添加图片 - 甚至是链接);显示您尝试过的内容;如果出现错误,请显示 logcat
-
我在列表视图中添加了文本视图。如果我在 text_view.xml 中设置 android:layout_height="60dp" ,例如,在我的设备中一切正常,但在其他项目上很大,它们无法放入 listview 并显示为滚动
-
我在我的适配器中使用了你的比例算法(我更新了我的帖子)。也许,我没听懂你的意思,但一切照旧
标签: android android-layout listview