Android百分比布局在全屏幕上将内容向左移动

时间:2017-04-25 13:15:13

标签: android android-layout

我正在设计一款应用,我遇到了一些问题。

正如您在设计器中看到的那样,所有元素都应该是它们(即时钟,右上角目标按钮和主刻度),而在仿真器中它们向左移动(尤其是时钟和按钮时)。

如果我不隐藏软件按钮,它似乎可以自行修复,但如果我显示软件按钮和工具栏(可能与屏幕比例相关?),它会再次出现。

我正在使用android.support.percent.PercentRelativeLayout

中的'com.android.support:percent:25.3.1'

有没有人遇到过类似的问题?

Shifted content

更新:这是布局本身:

<?xml version="1.0" encoding="utf-8"?>
<android.support.percent.PercentRelativeLayout 
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"
tools:context="com.tekorius.stalker.MainActivity"
android:background="@drawable/background"
android:keepScreenOn="true">

<com.tekorius.stalker.view.Geiger
    android:id="@+id/geiger"
    app:layout_widthPercent="52.604166667%"
    app:layout_heightPercent="93.5185185%"
    app:layout_marginLeftPercent="45%"
    app:layout_marginTopPercent="4%" />

<com.tekorius.stalker.view.Tube
    android:id="@+id/tube"
    app:layout_widthPercent="39.895833333%"
    app:layout_heightPercent="31.018518519%"
    app:layout_marginTopPercent="60%"
    app:layout_marginLeftPercent="52%" />

<com.tekorius.stalker.view.ArmorBar
    android:id="@+id/armorbar"
    app:layout_widthPercent="46.302083333%"
    app:layout_heightPercent="10.185185185%"
    app:layout_marginTopPercent="3%"
    app:layout_marginLeftPercent="3.5%" />

<com.tekorius.stalker.view.StaminaBar
    android:id="@+id/staminabar"
    app:layout_widthPercent="46.302083333%"
    app:layout_heightPercent="11.666666667%"
    app:layout_marginTopPercent="13%"
    app:layout_marginLeftPercent="3.5%" />

<com.tekorius.stalker.view.Radbar
    android:id="@+id/radbar"
    app:layout_widthPercent="39.010416667%"
    app:layout_heightPercent="20.740740741%"
    app:layout_marginTopPercent="21.25%"
    app:layout_marginLeftPercent="3.5%" />

<com.tekorius.stalker.view.Healthbar
    android:id="@+id/healthbar"
    app:layout_widthPercent="39.010416667%"
    app:layout_heightPercent="20.740740741%"
    app:layout_marginTopPercent="42.25%"
    app:layout_marginLeftPercent="3.5%" />

<ImageButton
    android:id="@+id/qrbutton"
    android:background="@drawable/qr_button"
    app:layout_widthPercent="8.072916667%"
    app:layout_heightPercent="14.351851852%"
    app:layout_marginLeftPercent="89.5%"
    app:layout_marginTopPercent="2%" />

<com.tekorius.stalker.view.Clock
    android:id="@+id/clock"
    app:layout_widthPercent="10.15625%"
    app:layout_heightPercent="7.87037037%"
    app:layout_marginLeftPercent="88.75%"
    app:layout_marginTopPercent="84.4%" />

<com.tekorius.stalker.view.Clock
    android:id="@+id/battery"
    app:layout_widthPercent="10.15625%"
    app:layout_heightPercent="7.87037037%"
    app:layout_marginLeftPercent="43.5%"
    app:layout_marginTopPercent="84.4%" />

<Button
    app:layout_widthPercent="10.15625%"
    app:layout_heightPercent="7.87037037%"
    app:layout_marginLeftPercent="23.5%"
    app:layout_marginTopPercent="84.4%"
    android:text="Start game service"
    android:onClick="startGameService" />

</android.support.percent.PercentRelativeLayout>

0 个答案:

没有答案