I'm facing a problem which I do not understand. In my activity_main.xml a relative Layout is defined which encapsulates a LinearLayout with ImageViews and a ListView.
<?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" />
I have implemented a ListAdapter and set it to my ListView in the WorkDayListActivity.
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);
}
//...
}
Now the drawable images which are basically pngs do not render. If I initilise them in the WorkDayListActivity they render on top of each other and not according to the defined position.
Can anybody explain me why this is the case? Your help is much appreciated!
Thank You!