简体   繁体   English

为什么我的 android 应用程序在模拟器中运行良好,但在真实设备中显示非常糟糕/

[英]why my android app works fine in emulator but display is totally terrible in real device/

i made an android app and it looks good in different screen sizes in emulator but when i run it in a real device, it runs but the display is totally terrible.我制作了一个 android 应用程序,它在模拟器中的不同屏幕尺寸下看起来不错,但是当我在真实设备上运行它时,它运行但显示非常糟糕。 i am using linear layout in my XML and my code for it is below.我在我的 XML 中使用线性布局,我的代码如下。 i have a table with some rows which contains data.我有一个表,其中包含一些包含数据的行。 it fits good with emulator but with real device the apps runs but display is totally bad.它非常适合模拟器,但对于真实设备,应用程序可以运行,但显示效果很差。 do not get it why runs good in emulator and bad in real device although its same resolution!不明白为什么在模拟器中运行良好而在真实设备中运行不佳,尽管其分辨率相同!

https://imgur.com/meYkj5T on emulator https://imgur.com/meYkj5T在模拟器上

https://imgur.com/cfv8PlG running on emulator https://imgur.com/cfv8PlG在模拟器上运行

https://imgur.com/oaGVt7J running on real device https://imgur.com/oaGVt7J在真实设备上运行

https://imgur.com/8alDEZC linearlayout width and height is match parent https://imgur.com/8alDEZC 线性布局宽度和高度与父级匹配

<?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    tools:context=".MainActivity">

    <ScrollView
        android:id="@+id/layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dip"
        android:fillViewport="true"
        android:scrollbarStyle="outsideInset"
        android:scrollbars="horizontal|vertical">

        <HorizontalScrollView
            android:id="@+id/horizontalView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="5dip"
            android:scrollbars="horizontal|vertical">


            <TableLayout

                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:gravity="center"
                android:shrinkColumns="*"
                android:stretchColumns="*"
                android:weightSum="10">



                <TableRow
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:weightSum="5"
                    android:layout_margin="1dp"
                    android:background="@drawable/border"
                    >

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_column="0"
                        android:layout_margin="1dp"
                        android:gravity="center"
                        android:text=" IP "
                        android:textAppearance="?android:attr/textAppearanceLarge"
                        android:textStyle="bold"
                        android:weightSum="10"
                        app:autoSizeTextType="uniform" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_column="1"
                        android:layout_margin="1dp"
                        android:gravity="center"
                        android:text=" "
                        android:textAppearance="?android:attr/textAppearanceLarge"
                        android:textStyle="bold"
                        android:weightSum="10"
                        app:autoSizeTextType="uniform" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_column="2"
                        android:layout_margin="1dp"
                        android:gravity="center"
                        android:text=""
                        android:textAppearance="?android:attr/textAppearanceLarge"
                        android:textStyle="bold"
                        android:weightSum="10"
                        app:autoSizeTextType="uniform" />
                </TableRow>

                <TableRow
                    android:id="@+id/tableRow0"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_column="0"
                    android:layout_margin="1dp"

                    >

                    <TextView
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:layout_column="0"
                        android:layout_margin="1dp"
                        android:gravity="center"
                        android:text=" "
                        android:textAppearance="?android:attr/textAppearanceLarge"
                        android:textSize="14dp"
                        android:textStyle="bold" />

                    <TextView
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:layout_column="1"
                        android:layout_margin="1dp"
                        android:gravity="center"
                        android:text=" "
                        android:textAppearance="?android:attr/textAppearanceLarge"
                        android:textSize="14dp"
                        android:textStyle="bold" />

                    <TextView
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:layout_column="2"
                        android:layout_margin="1dp"
                        android:gravity="center"
                        android:text=""
                        android:textAppearance="?android:attr/textAppearanceLarge"
                        android:textSize="14dp"
                        android:textStyle="bold"
                        app:autoSizeTextType="uniform" />
                </TableRow>


                <TableRow
                    android:id="@+id/tableRow1"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_column="0"
                    android:layout_margin="1dp">

                    <TextView
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:layout_column="0"
                        android:layout_margin="1dp"
                        android:gravity="center"
                        android:text=" "
                        android:textAppearance="?android:attr/textAppearanceLarge"
                        android:textSize="14dp"
                        android:textStyle="bold" />

                    <TextView
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:layout_column="1"
                        android:layout_margin="1dp"
                        android:gravity="center"
                        android:text=""
                        android:textAppearance="?android:attr/textAppearanceLarge"
                        android:textSize="14dp"
                        android:textStyle="bold"
                        app:autoSizeTextType="uniform" />

                    <TextView
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:layout_column="2"
                        android:layout_margin="1dp"
                        android:gravity="center"
                        android:text=" "
                        android:textAppearance="?android:attr/textAppearanceLarge"
                        android:textSize="14dp"
                        android:textStyle="bold" />
                </TableRow>



 </TableLayout>
        </HorizontalScrollView>
    </ScrollView>
</LinearLayout>


You have added weightsum for you TableRow.您已经为您的 TableRow 添加了 weightsum。 You need to make changes as below -您需要进行如下更改 -

Replace weightsum for first TableRow to 3将第一个 TableRow 的 weightsum 替换为 3

            <TableRow
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:weightSum="3"
                android:layout_margin="1dp"
                android:background="@drawable/border">

Also remove below line from Child TextViews同时从 Child TextViews 中删除下面的行

android:weightSum="10"

Add below lines to Child TextViews将以下行添加到子 TextViews

android:layout_width="0dp"
android:layout_weight="1"

I hope it will work for you.我希望它对你有用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我的应用程序在我的 android 仿真器上运行良好,但在我的真实 android 设备上运行不正常 - Why my app is working fine on my android emulator but its not working fine on my real android device Android应用程式可在模拟器上正常运作,但在真实装置中当机 - Android app works fine in emulator but crashes in real device Android应用程序可以在模拟器中正常运行,但不能在真实设备中运行? - Android application works fine in emulator but not in real device? Android应用程序可以在模拟器上正常运行,但不能在真实设备上运行 - Android Application works fine on emulator but not on a real device 在模拟器中,我的应用可以正常运行,但不能在真实设备中运行 - In emulator my app running fine but not in real device SQLite数据库Android应用程序在模拟器中无法在我的设备中正常运行 - SQLite database Android app works fine in emulator not in my device Android 应用程序在少数真实设备上崩溃,但在与真实设备具有相同 API 的模拟器上运行良好 - Android app crashes on few real devices but works fine on an emulator which has the same API as that of the real device 我的应用程序只能在模拟器上运行,而不能在真实设备上运行 - My app works only on emulator, not on the real device Android Studio 应用程序可以在模拟器中运行,但不能在真实设备上运行 - Android Studio app works in emulator but not on a real device Android App可在模拟器上运行,但不能在真实设备上运行 - Android App works on emulator, but not on real device
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM