2016-01-28 44 views
0

我为我的应用程序创建了图标和按钮,并将它们放到我的Android Studio项目中。Android Studio对象在模拟器/智能手机上的位置

在模拟器中它看起来像这样:

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'。堆栈溢出充满了这类问题。请先彻底搜索,然后询问您是否有任何疑问或问题。 –

+0

我将xml文件添加到问题中。 – nxtSimon

+0

好的,我需要添加评论。 – 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岁,几乎与你年龄相仿! :)你能解释一点点吗?你的物体在哪里移动?我很乐意帮助你。 :) –

相关问题