PercentRelativeLayout
を実装しました。私は、compile 'com.android.support:percent:24.2.0'
をgradleに追加して、Android Studioが少なくともそのビューを認識できるようにしました。 Google APIを追加しました。PercentRelativeLayoutエミュレータで大丈夫です。電話では大丈夫ではありません。
レンダリングに問題があります。エミュレータでは、私のディスプレイが正常に動作します。 Android 4ishを実行している古い携帯電話にインストールすると、TextViewが表示されますが、画像ビューは表示されません。プレビューで
は(デザイン]タブで)ImageViewsをレンダリング私はこれがちょうど仕事をしていたように感じAPI 24
私はAPI 23に切り替えたときに表示されますが、ではありません。これに関する既知の修正?残念ながら、私のレイアウトを拡大するにはビューが不可欠です。
EDIT:いくつかのAndroidスタジオを再起動すると、プレビューが突然再現されます。何も変えなかった
レイアウトは、API 16までのすべての方法でプレビューで機能しますが、まだ電話では機能しません。 ImageViewsが表示されません。
<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