in my android app, I use a simple screen with an MPandroidchart wrapped in a RelativeLayout and a back button at the top. The button does not respond.
The button (clickable imageview) does work as intended, if I change the RelativeLayout into LinearLayout. However, I do need RelativeLayout to get my MPAndroidchart working. Any Ideas how to make the button work?
THe button should be at the top left, above the chart.
XML below:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
android:orientation="vertical"
tools:context="com.example.erik.myroom.Frontend.Fragment_Statistic">
<ImageView
android:id="@+id/back_from_statistic"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_weight="1"
android:gravity="center_vertical|start"
android:layout_marginTop="@dimen/material_drawer_vertical_padding"
android:clickable="true"
app:ico_color="@color/md_black_1000"
app:ico_icon="@string/gmd_arrow_back"
app:ico_size="16dp"/>
<com.github.mikephil.charting.charts.HorizontalBarChart
android:id="@+id/testchart"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
</layout>
The ImageView
is not disabled, but it is covered by the HorizontalBarChart
.
Remove these attributes from the ImageView
:
android:layout_weight="1"
android:gravity="center_vertical|start"
because they are valid only in a LinearLayout
and set these attributes:
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
and also set this attribute:
android:layout_below="@id/back_from_statistic"
for the HorizontalBarChart
.