簡體   English   中英

如何解決不同屏幕中的應用顯示問題?

[英]How to fix app display issue in different screen?

為什么我的應用顯示因設備而異

這是 output 我正在安裝一些設備

這是一些設備的output,你可以清楚地看到右側正在切割

請幫助我從不同設備的各個方面修復我的應用程序 UI,例如圖像1

我的 XML 代碼

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
android:background="@drawable/bg_pic"
tools:context=".MainActivity">


<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="33dp"
        android:layout_height="27dp"
        android:layout_marginLeft="15dp"
        android:layout_marginTop="10dp"
        app:srcCompat="@drawable/close_btn" />

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="135dp"
            android:layout_marginTop="5dp"
            android:gravity="center">

            <TextView
                android:id="@+id/imageView2"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:background="@drawable/timer"
                android:gravity="center"
                android:text="15s"
                android:textSize="20dp"
                android:textColor="#3B3B3B"
                android:textStyle="bold" />
                </LinearLayout>

        <TextView
            android:id="@+id/textView"
            android:layout_width="97dp"
            android:layout_height="40dp"
            android:layout_marginLeft="80dp"
            android:layout_marginTop="10dp"
            android:gravity="center"
            android:text="Score: 430"
            android:textColor="#000"
            android:textSize="18dp" />

</LinearLayout>


</RelativeLayout>

您可以通過使用weightSum如下實現此目的

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:weightSum="1">

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="0dp"
        android:layout_height="30dp"
        android:layout_weight=".2"
        app:srcCompat="@drawable/close_btn" />

    <TextView
        android:id="@+id/imageView2"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight=".4"
        android:background="@drawable/timer"
        android:gravity="center"
        android:text="15s"
        android:textColor="#3B3B3B"
        android:textSize="20dp"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/textView"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight=".4"
        android:gravity="center"
        android:text="Score: 430"
        android:textColor="#000"
        android:textSize="18dp" />

</LinearLayout>

在此處輸入圖像描述

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM