0

I created icons and buttons for my app and put them in my Android Studio project.

In the Emulator it looks like this:

Emulator View

But on my phone it looks like this:

Phone View

What can I do or how can I scale the icons for every resolution perfectly?

Thanks for every answer.

Layout xml file:

<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent" android:layout_height="match_parent">

    <ImageView
        android:layout_width="1052dp"
        android:layout_height="wrap_content"
        android:id="@+id/imageView"
        android:layout_x="-321dp"
        android:layout_y="137dp"
        android:background="@drawable/barline"/>

    <ImageButton
        android:layout_width="150dp"
        android:layout_height="90dp"
        android:id="@+id/imageButton"
        android:layout_x="-10dp"
        android:layout_y="478dp"
        android:background="@drawable/bewertung"
        android:contentDescription="" />

    <ImageButton
        android:layout_width="150dp"
        android:layout_height="90dp"
        android:id="@+id/imageButton2"
        android:layout_x="270dp"
        android:layout_y="477dp"
        android:background="@drawable/bekanntheit"
        android:contentDescription="" />

    <ImageButton
        android:layout_width="150dp"
        android:layout_height="90dp"
        android:id="@+id/imageButton3"
        android:layout_x="172dp"
        android:layout_y="477dp"
        android:background="@drawable/crew"
        android:contentDescription="" />

    <ImageButton
        android:layout_width="150dp"
        android:layout_height="90dp"
        android:id="@+id/imageButton4"
        android:layout_x="85dp"
        android:layout_y="477dp"
        android:background="@drawable/einkaufswagen"
        android:contentDescription="" />
nxtSimon
  • 1
  • 3
  • Please include your xml layout file. You will also need to use `layout_weight`. Stack Overflow is full of this kind of questions. Please search thoroughly first, then ask if you have any inquiries or problems. – Hussein El Feky Jan 28 '16 at 20:16
  • I added the xml file to the question.. – nxtSimon Jan 29 '16 at 10:07
  • ok, I need to add a comment.. – nxtSimon Jun 02 '17 at 13:31
  • Hello SimonVJava, I have just added a slight edit to my answer. You only need to specify a `layout_height` for each view instead of using `wrap_content` because `wrap_content` will use the drawable's default height and won't wrap it according to the children height, and I'm sure this is what happened to you. – Hussein El Feky Jun 10 '17 at 15:15

1 Answers1

0

Use a LinearLayout with orientation set to horizontal, then define layout_weight for each view you have:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="80dp"
    android:orientation="horizontal"
    android:gravity="center"
    android:background="@drawable/barline">

    <ImageButton
        android:layout_width="0dp"
        android:layout_height="60dp"
        android:layout_weight="1"
        android:id="@+id/imageButton"
        android:background="@drawable/bewertung"
        android:contentDescription="" />

    <ImageButton
        android:layout_width="0dp"
        android:layout_height="60dp"
        android:layout_weight="1"
        android:id="@+id/imageButton2"
        android:background="@drawable/bekanntheit"
        android:contentDescription="" />

    <ImageButton
        android:layout_width="0dp"
        android:layout_height="60dp"
        android:layout_weight="1"
        android:id="@+id/imageButton3"
        android:background="@drawable/crew"
        android:contentDescription="" />

    <ImageButton
        android:layout_width="0dp"
        android:layout_height="60dp"
        android:layout_weight="1"
        android:id="@+id/imageButton4"
        android:background="@drawable/einkaufswagen"
        android:contentDescription="" />

</LinearLayout>
Hussein El Feky
  • 6,627
  • 5
  • 44
  • 57
  • Thank you so much. <3 Thats so polite. Have you already created published Apps? – nxtSimon Jan 29 '16 at 12:20
  • :c Nothing is working.. If I want to put 1 Objekt down left, all other Objekts move to. Sorry I'm a beginner and only 14 :c – nxtSimon Jan 29 '16 at 13:06
  • No problem, and yes I have published 2 apps. You can check them from my profile. I am also 16, somewhere near your age! :) Can you please explain a little bit more? Where did your objects move? I'll be glad to help you. :) – Hussein El Feky Jan 29 '16 at 13:12
  • Okay, I'll check out your 2 Apps afterwards! So I'll try explain a little bit more, whats my problem is.. – nxtSimon Jan 29 '16 at 14:52
  • If I want to move a objekt (invisible) to another place like this: http://prntscr.com/9weht0 This will happen: http://prntscr.com/9wekh1 – nxtSimon Jan 29 '16 at 15:05
  • You posted the same link in your last comment, but anyway I think I got what you meant. You will need to understand the difference between LinearLayout and RelativeLayout. You can check the accepted answer in this link, including the link he mentioned: http://stackoverflow.com/questions/4905370/what-are-the-differences-between-linearlayout-relativelayout-and-absolutelayou You will need to use LinearLayout and RelativeLayout together in your case. If you want me to create the layout for you, just draw what you want on any program or paper, and I will create it for you. – Hussein El Feky Jan 29 '16 at 15:18
  • But it's better to understand all types of layout too. – Hussein El Feky Jan 29 '16 at 15:23
  • Ok, thanks again for your answer! I can send you the .png files and a image how it should look like.. The .pngs are for another projekt, but I think this doesnt matter.. How can I send you the files?? – nxtSimon Jan 29 '16 at 17:30
  • PS: Can you open a chat?? I think we shouldn't do that in the comments.. (: – nxtSimon Jan 29 '16 at 17:35
  • @SimonVJava I don't know how to start a chat here. If you could start it, it will be great! Sorry for the late response. :) – Hussein El Feky Jan 30 '16 at 22:02
  • I don't know too :c But how can I send you the files?? – nxtSimon Jan 31 '16 at 13:13
  • I'm not sure, but maybe try chatting with me here: http://chat.stackoverflow.com/rooms/102175/discussion-between-hussein-el-feky-and-simonvjava – Hussein El Feky Jan 31 '16 at 21:19