PercentRelativeLayout auf dem Emulator in Ordnung, auf dem Telefon nicht in Ordnung
Ich habe gerade implementiertPercentRelativeLayout
. Ich habe hinzugefügt:compile 'com.android.support:percent:24.2.0'
an den gradle damit Android Studio zumindest die ansicht erkennt. Und die Google-API hinzugefügt.
Ich habe Probleme beim Rendern. Im Emulator funktioniert meine Anzeige einwandfrei. Auf einem älteren Telefon mit Android 4ish installiert, werden TextViews angezeigt, jedoch keine Bildansichten.
Im Vorschau-Rendering (im Design-Tab) werden die ImageViews angezeigt, wenn ich auf API 23, aber nicht auf API 24 umschalte.
Ich fühle mich wie dies gerade funktioniert. Bekannte Fehlerbehebungen? Leider ist die Ansicht wichtig, um mein Layout zu skalieren.
EDIT: Die Vorschau funktioniert plötzlich wieder bei mehreren neu gestarteten Android Studios. Hat sonst nichts geändert.
Das Layout funktioniert in der Vorschau bis zur API 16, funktioniert aber auf dem Telefon immer noch nicht. ImageViews werden nicht angezeigt.
XML Below
<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="fill_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.example.y"
tools:showIn="@layout/app_bar_main"
android:background="#FFF"
android:weightSum="1"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/scrollView"
android:scrollIndicators="top">
<android.support.percent.PercentRelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="This text appears correctly"
android:textSize="28sp"
android:id="@+id/textMainTitle"
android:layout_gravity="center"
android:layout_alignParentTop="true"
android:textColor="#ffffff"
android:singleLine="true"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="As does this text"
android:id="@+id/textMainSubTitle"
android:layout_gravity="center_horizontal"
android:layout_below="@id/textMainTitle"
/>
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/btnIntro"
android:src="@drawable/button1" //DOES NOT APPEAR IN PHONE
app:layout_widthPercent="30%"
app:layout_heightPercent="25%"
android:layout_below="@id/textMainSubTitle"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp" />
</android.support.percent.PercentRelativeLayout>
</ScrollView>
</LinearLayout>