2016-01-28 2 views
0

Я создал значки и кнопки для своего приложения и поместил их в свой проект Android Studio.Android Studio Objects Position on Emulator/SmartPhone

В эмуляторе это выглядит следующим образом:

Emulator View

Но на моем телефоне это выглядит следующим образом:

Phone View

Что я могу сделать, или как я могу масштабировать иконки для каждого разрешения отлично?

Спасибо за каждый ответ.

Компоновка файл XML:

<?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="" />

+0

Пожалуйста, включите раскладку XML файл. Вам также нужно будет использовать 'layout_weight'. Stack Overflow полон таких вопросов. Сначала сначала выполните поиск, а затем спросите, есть ли у вас какие-либо вопросы или проблемы. –

+0

Я добавил файл xml на вопрос .. – nxtSimon

+0

ok, мне нужно добавить комментарий .. – nxtSimon

ответ

0

Используйте LinearLayout с ориентацией установить в горизонтальное положение, а затем определить layout_weight для каждого просмотра у Вас есть:

<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> 
+0

Большое вам спасибо. <3 Это так вежливо. Вы уже создали опубликованные приложения? – nxtSimon

+0

: c Ничего не работает. Если я хочу поставить 1 объект вниз, все остальные объекты перемещаются. Извините, что я новичок и только 14: c – nxtSimon

+0

Нет проблем, и да, я опубликовал 2 приложения. Вы можете проверить их из моего профиля. Мне также 16 лет, где-то рядом с вашим возрастом! :) Не могли бы вы объяснить немного больше? Куда двигались ваши объекты? Я буду рад помочь вам. :) –