首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Android Studio对象在Emulator/SmartPhone上的位置

Android Studio对象在Emulator/SmartPhone上的位置
EN

Stack Overflow用户
提问于 2016-01-29 04:05:12
回答 1查看 722关注 0票数 0

我为我的应用程序创建了图标和按钮,并将它们放入我的Android Studio项目中。

在Emulator中,它看起来像这样:

但在我的手机上看起来是这样的:

我能做什么,或者我如何完美地缩放每个分辨率的图标?

感谢你的每一个回答。

布局xml文件:

代码语言:javascript
复制
<?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="" />

EN

回答 1

Stack Overflow用户

发布于 2016-01-29 19:22:08

使用方向设置为水平的LinearLayout,然后为您拥有的每个视图定义layout_weight

代码语言:javascript
复制
<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
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35070983

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档