我遇到了一个我不明白的问题。在我的activity_main.xml中,定义了一个相对布局,它使用ImageViews和ListView封装LinearLayout。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:context="de.opti4apps.timely.app.WorkDayListActivity">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/lst_workday_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/activity_vertical_margin"
android:layout_marginRight="@dimen/activity_vertical_margin"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:adjustViewBounds="false"
android:scaleType="fitCenter"
android:visibility="visible"
app:srcCompat="@drawable/date" />
<--...-->
</LinearLayout>
<ListView
android:id="@+id/ManageWorkTimeList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/lst_workday_header"
android:layout_marginLeft="@dimen/activity_vertical_margin"
android:layout_marginRight="@dimen/activity_vertical_margin" />
我已经实现了一个ListAdapter并将其设置为WorkDayListActivity中的ListView。
public class WorkDayListActivity extends Activity{
private final List<Day> items = new ArrayList<>();
private DayDataSource dayDataSource = new DayDataSource(this);
private ListView manageWorkTimeList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getActionBar().setDisplayHomeAsUpEnabled(true);
manageWorkTimeList = (ListView) findViewById(R.id.ManageWorkTimeList);
dayDataSource.open();
items.addAll(dayDataSource.getAllDays());
dayDataSource.close();
WorkTimeListAdapter adapter = new WorkTimeListAdapter(this,0,items);
manageWorkTimeList.setAdapter(adapter);
}
//...
}
现在基本上是png的可绘制图像不会渲染。如果我在WorkDayListActivity中初始化它们,则它们在彼此之上呈现而不是根据定义的位置。
任何人都能解释一下为什么会这样吗?非常感谢您的帮助!
谢谢!