Я только что внедрил PercentRelativeLayout
. Я добавил: compile 'com.android.support:percent:24.2.0'
к градиенту, поэтому Android Studio по крайней мере распознает представление. И добавил API Google.PercentRelativeLayout хорошо на эмуляторе, не совсем по телефону
У меня проблемы с рендерингом. В эмуляторе мой дисплей работает нормально. Установленные на более раннем телефоне под управлением Android 4ish, появляются текстовые элементы, но не изображения.
В предварительном просмотре визуализации (на вкладке дизайн) в ImageViews показать при переходе на API 23, но не API 24.
Я чувствую, что это было просто работать. Любые известные исправления к этому? К сожалению, представление имеет важное значение для масштабирования моего макета.
EDIT: предварительный просмотр неожиданно возобновляется с несколькими перезапусками андроид-студии. Больше ничего не изменил.
Макет работает в режиме предварительного просмотра вплоть до API 16, но все еще не работает на телефоне. ImageViews не отображаются.
XML Ниже
<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>
Вам нужно будет включить ваш макет xml, если вы хотите помочь отлаживать xml вашего макета. – ianhanniballake
Справедливая точка. добавленной – BR89