プログラムをデバッグして携帯電話で実行すると、Androidスタジオでデザインしたものが携帯電話に表示されません。相対レイアウトを使用する場合、制約レイアウトに切り替えると、これが表示されます。問題が発生します。デバッグ時にAndroid StudioでAndroidアプリケーションを表示できない電話機
図1は、Android Studioおよび図2から取られた私のアプリケーションの意図した設計のスナップショットは、私の携帯電話自体
Intended Design (Fig 1) Outcome image (Fig 2)
XMLコード
から取られたアプリケーションの結果であります<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
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:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.jasonkym.safstrengthcounter.MainActivity"
android:background="@android:color/background_dark">
<TextView
android:text="No. of blank files:"
android:layout_width="84dp"
android:layout_height="41dp"
android:id="@+id/tvtNoOfBlankFiles"
android:textStyle="normal|bold"
android:textColor="@android:color/holo_orange_light"
tools:layout_editor_absoluteY="160dp"
tools:layout_editor_absoluteX="25dp" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="10"
android:id="@+id/etxNoOfBlankFiles"
android:textColor="@android:color/holo_green_dark"
android:text="0"
android:textStyle="normal|bold|italic"
tools:layout_editor_absoluteY="158dp"
tools:layout_editor_absoluteX="117dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tvtResults"
android:textSize="24sp"
android:textStyle="normal|bold"
android:textColor="@android:color/holo_blue_bright"
tools:layout_editor_absoluteX="121dp"
tools:layout_editor_absoluteY="415dp" />
<TextView
android:text="No. of people per column:"
android:layout_width="88dp"
android:layout_height="43dp"
android:id="@+id/tvtNoOfPeoplePerRow"
android:textStyle="normal|bold"
android:textColor="@android:color/holo_orange_light"
tools:layout_editor_absoluteX="25dp"
tools:layout_editor_absoluteY="234dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SAF Strength Counter"
android:id="@+id/tvtStrengthCounterLabel"
android:textStyle="normal|bold"
android:textSize="30sp"
android:textColor="@android:color/holo_red_dark"
tools:layout_editor_absoluteX="35dp"
tools:layout_editor_absoluteY="32dp" />
<TextView
android:text="Made by PTE Koh Yi Min Jason"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tvtMadebyKohYiMinJason"
tools:layout_editor_absoluteY="478dp"
tools:layout_editor_absoluteX="84dp" />
<TextView
android:text="No. of people behind:"
android:layout_width="87dp"
android:layout_height="44dp"
android:id="@+id/tvtNoOfPeopleBehind"
android:textStyle="normal|bold"
android:textColor="@android:color/holo_orange_light"
tools:layout_editor_absoluteX="23dp"
tools:layout_editor_absoluteY="314dp" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="10"
android:id="@+id/etxNoOfPeopleBehind"
android:textStyle="normal|bold|italic"
android:text="0"
android:textColor="@android:color/holo_green_dark"
tools:layout_editor_absoluteY="315dp"
tools:layout_editor_absoluteX="118dp" />
<TextView
android:text="No. of column:"
android:layout_width="82dp"
android:layout_height="43dp"
android:id="@+id/tvtNumberOfRows"
android:textStyle="normal|bold"
android:textColor="@android:color/holo_orange_light"
tools:layout_editor_absoluteX="27dp"
tools:layout_editor_absoluteY="91dp" />
<Button
android:text="Calculate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnCalculate"
tools:layout_editor_absoluteY="407dp"
tools:layout_editor_absoluteX="236dp" />
<TextView
android:text="Result:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tvtResultsLabel"
android:textSize="24sp"
android:textStyle="normal|bold"
android:textColor="@android:color/holo_orange_light"
tools:layout_editor_absoluteY="415dp"
tools:layout_editor_absoluteX="26dp" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="10"
android:id="@+id/etxNoOfRows"
android:textColor="@android:color/holo_green_dark"
android:text="0"
android:textStyle="normal|bold|italic"
tools:layout_editor_absoluteY="91dp"
tools:layout_editor_absoluteX="115dp" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="10"
android:id="@+id/etxNoOfPeoplePerRow"
android:textColor="@android:color/holo_green_dark"
android:text="0"
android:textStyle="normal|bold|italic"
tools:layout_editor_absoluteY="234dp"
tools:layout_editor_absoluteX="121dp" />
</android.support.constraint.ConstraintLayout>
図1で撮影したスクリーンショットは、ConstraintLayoutでのアプリケーションの意図したデザインでした。私の電話機は、スタジオでデザインしたものと全く同じものを表示するべきではありません。スタジオに表示されるように制約レイアウトのコードを追加する必要がありますか?私はEditTextとTextViewのすべてが画面の左上隅にあるように見えるので、WidgetとTextViewを意図した場所に配置するにはコード行を入力する必要があります。 –
あなたのXMLコードを送ってください。 –