0

I dont understand Why nothing appears on the display. I can see the Button and the ImageView (zauberer) but otherwise nothing.. can someone help me?

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/halbtransparent">


    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:srcCompat="@drawable/dialoghintergrund"
        android:id="@+id/willdialog"
        android:layout_margin="20dp" />


    <ImageView
        android:scaleType="fitXY"
        android:id="@+id/zauberer"
        android:layout_marginTop="40dp"
        android:layout_marginLeft="50dp"
        android:layout_marginStart="50dp"
        app:srcCompat="@drawable/zaubererdialoghg"
        android:layout_height="55dp"
        android:layout_width="43dp" />

    <ImageButton
        android:id="@+id/btn_verstanden"
        android:scaleType="fitXY"
        android:layout_width="130dp"
        android:layout_marginTop="410dp"
        android:layout_gravity="center_horizontal"
        android:background="#00000000"
        android:layout_height="50dp"
        app:srcCompat="@drawable/btn_verstanden"/>

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
jordy
  • 51
  • 5
  • I think your problem is `srcCompat` as said in this link http://stackoverflow.com/questions/40624554/android-what-is-the-difference-between-appsrccompat-and-androidsrc – Vivek Mishra Mar 20 '17 at 07:37

3 Answers3

1

Nothing is displayed in Activity or Android Studio? Have you closed the Framelayout tag? try to use Relativelayout. Make sure you have setContentView in your Activity.

Ali Akhgar
  • 101
  • 1
  • 10
1

This happens because child layouts in FrameLayout overlap each other and the child written at the bottom is drawn over the others. Use LinearLayout with orientation set to vertical to resolve the problem.

Harsh Ganatra
  • 411
  • 3
  • 8
1

Couple of suggestion:

  1. fill_parent is deprecated use match_parent

  2. use android:src instead of app:srcCompat

  3. you are using static Dp values android:layout_marginTop="410dp" which will be varied in different devices according to pixel density.

use layout_weight , weightSum , adJustViewBounds , Gravity to align your views..

  1. Best practice to use different size drawable iamges in your mdpi , hdpi , xhdpi etc folder.

Try this:

<LinearLayout 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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/colorPrimary"
    android:orientation="vertical">


    <ImageView
        android:id="@+id/willdialog"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="20dp"
        android:src="@mipmap/ic_launcher" />


    <ImageView
        android:id="@+id/zauberer"
        android:layout_width="43dp"
        android:layout_height="55dp"
        android:layout_marginLeft="50dp"
        android:layout_marginStart="50dp"
        android:layout_marginTop="40dp"
        android:scaleType="fitXY"
        android:src="@mipmap/ic_launcher" />

    <ImageButton
        android:id="@+id/btn_verstanden"
        android:layout_width="130dp"
        android:layout_height="50dp"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="100dp"
        android:background="#00000000"
        android:scaleType="fitXY"
        android:src="@mipmap/ic_launcher" />

</LinearLayout>
rafsanahmad007
  • 23,683
  • 6
  • 47
  • 62