【发布时间】:2016-07-03 19:57:57
【问题描述】:
我刚刚实现了PercentRelativeLayout。我在 gradle 中添加了:compile 'com.android.support:percent:24.2.0',因此 Android Studio 至少可以识别视图。并添加了 Google API。
我遇到了渲染问题。在模拟器中,我的显示器工作正常。安装在运行 Android 4ish 的旧手机上,出现 TextViews 但不显示图像视图。
在预览渲染中(在设计选项卡中),当我切换到 API 23 而不是 API 24 时,ImageViews 会显示。
我觉得这只是工作。对此有任何已知的修复吗?不幸的是,视图对于缩放我的布局至关重要。
编辑:预览突然又重新启动了几次 android studio。没有改变其他任何东西。
该布局在预览版中一直有效,直至 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。
标签: android android-layout android-studio